source: trunk/gsdl/perllib/plugins/RecPlug.pm@ 75

Last change on this file since 75 was 4, checked in by sjboddie, 26 years ago

Initial revision

  • 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
4package RecPlug;
5
6use BasPlug;
7use plugin;
8
9
10BEGIN {
11 @ISA = ('BasPlug');
12}
13
14sub new {
15 my ($class) = @_;
16 my $self = new BasPlug ();
17
18 return bless $self, $class;
19}
20
21# return 1 if this class might recurse using $pluginfo
22sub is_recursive {
23 my $self = shift (@_);
24
25 return 1;
26}
27
28# return 1 if processed, 0 if not processed
29# Note that $base_dir might be "" and that $file might
30# include directories
31sub read {
32 my $self = shift (@_);
33 my ($pluginfo, $base_dir, $file, $metadata, $processor) = @_;
34
35
36 my (@dir, $subfile);
37
38 # see if this is a directory
39 if (-d "$base_dir$file") {
40
41 # read all the files in the directory
42 opendir (DIR, "$base_dir$file") ||
43 die "ERROR - couldn't read directory $base_dir$file\n";
44 @dir = readdir (DIR);
45 closedir (DIR);
46
47 # process each file
48 foreach $subfile (@dir) {
49 if ($subfile !~ /^\.\.?$/) {
50 # note: metadata is not carried on to the next level
51 my $tmp = "$file/$subfile";
52 $tmp =~ s/^[\\\/]+|[\\\/]+$//g; # remove extra slashes
53 &plugin::read ($pluginfo, $base_dir, $tmp, {}, $processor);
54 }
55 }
56
57 return 1;
58 }
59
60 # wasn't a directory, someone else will have to process it
61 return 0;
62}
63
64
651;
Note: See TracBrowser for help on using the repository browser.