Last change
on this file since 229 was 136, checked in by rjmcnab, 25 years ago |
Fixed small bug.
|
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.2 KB
|
Line | |
---|
1 | # plugin which recurses through directories processing
|
---|
2 | # each file it finds
|
---|
3 |
|
---|
4 | package RecPlug;
|
---|
5 |
|
---|
6 | use BasPlug;
|
---|
7 | use plugin;
|
---|
8 | use util;
|
---|
9 |
|
---|
10 |
|
---|
11 | BEGIN {
|
---|
12 | @ISA = ('BasPlug');
|
---|
13 | }
|
---|
14 |
|
---|
15 | sub new {
|
---|
16 | my ($class) = @_;
|
---|
17 | my $self = new BasPlug ();
|
---|
18 |
|
---|
19 | return bless $self, $class;
|
---|
20 | }
|
---|
21 |
|
---|
22 | # return 1 if this class might recurse using $pluginfo
|
---|
23 | sub is_recursive {
|
---|
24 | my $self = shift (@_);
|
---|
25 |
|
---|
26 | return 1;
|
---|
27 | }
|
---|
28 |
|
---|
29 | # return 1 if processed, 0 if not processed
|
---|
30 | # Note that $base_dir might be "" and that $file might
|
---|
31 | # include directories
|
---|
32 | sub read {
|
---|
33 | my $self = shift (@_);
|
---|
34 | my ($pluginfo, $base_dir, $file, $metadata, $processor) = @_;
|
---|
35 |
|
---|
36 |
|
---|
37 | my (@dir, $subfile);
|
---|
38 |
|
---|
39 | # see if this is a directory
|
---|
40 | $dirname = &util::filename_cat ($base_dir, $file);
|
---|
41 | if (-d $dirname) {
|
---|
42 |
|
---|
43 | # read all the files in the directory
|
---|
44 | opendir (DIR, $dirname) ||
|
---|
45 | die "ERROR - couldn't read directory $dirname\n";
|
---|
46 | @dir = readdir (DIR);
|
---|
47 | closedir (DIR);
|
---|
48 |
|
---|
49 | # process each file
|
---|
50 | foreach $subfile (@dir) {
|
---|
51 | if ($subfile !~ /^\.\.?$/) {
|
---|
52 | # note: metadata is not carried on to the next level
|
---|
53 | &plugin::read ($pluginfo, $base_dir, &util::filename_cat($file, $subfile),
|
---|
54 | {}, $processor);
|
---|
55 | }
|
---|
56 | }
|
---|
57 |
|
---|
58 | return 1;
|
---|
59 | }
|
---|
60 |
|
---|
61 | # wasn't a directory, someone else will have to process it
|
---|
62 | return 0;
|
---|
63 | }
|
---|
64 |
|
---|
65 |
|
---|
66 | 1;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.