1 |
ulpfr |
53 |
# -*- 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: Mon Dec 31 14:45:13 2001 |
8 |
|
|
# Language : CPerl |
9 |
|
|
# Update Count : 84 |
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(); |
51 |
|
|
return { desc => $desc, author => $author}; |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
sub FIRSTKEY { |
55 |
|
|
my $self = shift; |
56 |
|
|
$self->{fno} = 0; |
57 |
|
|
$self->NEXTKEY; |
58 |
|
|
} |
59 |
|
|
|
60 |
|
|
sub NEXTKEY { |
61 |
|
|
my $self = shift; |
62 |
|
|
return undef if ($self->{fno}++ > @{$self->{Files}}); |
63 |
|
|
$self->{Files}->[$self->{fno}-1]; |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
sub close { |
67 |
|
|
my $self = shift; |
68 |
|
|
|
69 |
|
|
delete $self->{fno}; |
70 |
|
|
delete $self->{Files}; # no need at query time |
71 |
|
|
} |
72 |
|
|
|
73 |
|
|
1; |