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 |
|
---|
5 | package ArcPlug;
|
---|
6 |
|
---|
7 | use util;
|
---|
8 | use BasPlug;
|
---|
9 | use plugin;
|
---|
10 | use arcinfo;
|
---|
11 |
|
---|
12 | BEGIN {
|
---|
13 | @ISA = ('BasPlug');
|
---|
14 | }
|
---|
15 |
|
---|
16 | sub 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
|
---|
24 | sub 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
|
---|
33 | sub 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 |
|
---|
70 | 1;
|
---|