1 |
# -*- Mode: Cperl -*- |
2 |
# Nroff.pm -- |
3 |
# ITIID : $ITI$ $Header $__Header$ |
4 |
# Author : Ulrich Pfeifer |
5 |
# Created On : Mon Sep 16 19:04:37 1996 |
6 |
# Last Modified By: Ulrich Pfeifer |
7 |
# Last Modified On: Fri Jan 4 15:56:11 2002 |
8 |
# Language : CPerl |
9 |
# Update Count : 86 |
10 |
# Status : Unknown, Use with caution! |
11 |
# |
12 |
# Copyright (c) 1996-1997, Ulrich Pfeifer |
13 |
# |
14 |
|
15 |
package WAIT::Document::Ora; |
16 |
@ISA = qw(WAIT::Document::Base); |
17 |
require WAIT::Document::Base; |
18 |
|
19 |
use IO::File; |
20 |
use strict; |
21 |
use Carp; |
22 |
|
23 |
sub TIEHASH { |
24 |
my $type = shift; |
25 |
my $dir = shift; |
26 |
my @files; |
27 |
|
28 |
opendir(DIR, $dir) or croak "Could not open '$dir': $!"; |
29 |
for my $entry (readdir DIR) { |
30 |
if (-f "$dir/$entry/desc.html") { |
31 |
push @files, $entry; |
32 |
} |
33 |
} |
34 |
my $self = { |
35 |
Dir => $dir, |
36 |
Files => \@files |
37 |
}; |
38 |
bless $self, ref($type) || $type; |
39 |
} |
40 |
|
41 |
sub FETCH { |
42 |
my $self = shift; |
43 |
my $file = shift; |
44 |
|
45 |
local($/) = undef; |
46 |
|
47 |
my $fh = IO::File->new(join('/',$self->{Dir},$file,'desc.html')); |
48 |
my $desc = $fh->getline(); |
49 |
$fh = IO::File->new(join('/',$self->{Dir},$file,'author.html')); |
50 |
my $author = $fh->getline() if $fh; |
51 |
$fh = IO::File->new(join('/',$self->{Dir},$file,'index.html')); |
52 |
my $index = $fh->getline() if $fh; |
53 |
return { desc => $desc, author => $author, index => $index}; |
54 |
} |
55 |
|
56 |
sub FIRSTKEY { |
57 |
my $self = shift; |
58 |
$self->{fno} = 0; |
59 |
$self->NEXTKEY; |
60 |
} |
61 |
|
62 |
sub NEXTKEY { |
63 |
my $self = shift; |
64 |
return undef if ($self->{fno}++ > @{$self->{Files}}); |
65 |
$self->{Files}->[$self->{fno}-1]; |
66 |
} |
67 |
|
68 |
sub close { |
69 |
my $self = shift; |
70 |
|
71 |
delete $self->{fno}; |
72 |
delete $self->{Files}; # no need at query time |
73 |
} |
74 |
|
75 |
1; |