source: trunk/gsdl/perllib/plugins/ArcPlug.pm@ 433

Last change on this file since 433 was 317, checked in by sjboddie, 25 years ago

Added maxdocs option

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.7 KB
Line 
1# plugin which recurses through an archives.inf file
2# (i.e. the file generated in the archives directory
3# when an import is done), processing each file it finds
4
5package ArcPlug;
6
7use util;
8use BasPlug;
9use plugin;
10use arcinfo;
11
12BEGIN {
13 @ISA = ('BasPlug');
14}
15
16sub new {
17 my ($class) = @_;
18 my $self = new BasPlug ();
19
20 return bless $self, $class;
21}
22
23# return 1 if this class might recurse using $pluginfo
24sub is_recursive {
25 my $self = shift (@_);
26
27 return 1;
28}
29
30# return number of files processed, undef if can't process
31# Note that $base_dir might be "" and that $file might
32# include directories
33sub read {
34 my $self = shift (@_);
35 ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs) = @_;
36
37 my $count = 0;
38
39 # see if this has a archives information file within it
40 $archive_info_filename = &util::filename_cat($base_dir,$file,"archives.inf");
41
42 if (-e $archive_info_filename) {
43
44 # found an archives.inf file
45 print STDERR "ArcPlug: processing $archive_info_filename\n";
46
47 # read in the archives information file
48 my $archive_info = new arcinfo ();
49 $archive_info->load_info ($archive_info_filename);
50
51 my $file_list = $archive_info->get_file_list();
52
53 # process each file
54 foreach $subfile (@$file_list) {
55 last if (defined $maxdocs && $maxdocs =~ /\d/ && $count >= $maxdocs);
56
57 my $tmp = &util::filename_cat ($file, $subfile->[0]);
58 next if $tmp eq $file;
59 # note: metadata is not carried on to the next level
60 $count += &plugin::read ($pluginfo, $base_dir, $tmp, {}, $processor, $maxdocs);
61 }
62
63 return $count;
64 }
65
66 # wasn't an archives directory, someone else will have to process it
67 return undef;
68}
69
701;
Note: See TracBrowser for help on using the repository browser.