[537] | 1 | ###########################################################################
|
---|
| 2 | #
|
---|
| 3 | # ArcPlug.pm --
|
---|
| 4 | # A component of the Greenstone digital library software
|
---|
| 5 | # from the New Zealand Digital Library Project at the
|
---|
| 6 | # University of Waikato, New Zealand.
|
---|
| 7 | #
|
---|
| 8 | # Copyright (C) 1999 New Zealand Digital Library Project
|
---|
| 9 | #
|
---|
| 10 | # This program is free software; you can redistribute it and/or modify
|
---|
| 11 | # it under the terms of the GNU General Public License as published by
|
---|
| 12 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 13 | # (at your option) any later version.
|
---|
| 14 | #
|
---|
| 15 | # This program is distributed in the hope that it will be useful,
|
---|
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 18 | # GNU General Public License for more details.
|
---|
| 19 | #
|
---|
| 20 | # You should have received a copy of the GNU General Public License
|
---|
| 21 | # along with this program; if not, write to the Free Software
|
---|
| 22 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 23 | #
|
---|
| 24 | ###########################################################################
|
---|
| 25 |
|
---|
[317] | 26 | # plugin which recurses through an archives.inf file
|
---|
| 27 | # (i.e. the file generated in the archives directory
|
---|
| 28 | # when an import is done), processing each file it finds
|
---|
[4] | 29 |
|
---|
| 30 | package ArcPlug;
|
---|
| 31 |
|
---|
| 32 | use util;
|
---|
| 33 | use BasPlug;
|
---|
| 34 | use plugin;
|
---|
| 35 | use arcinfo;
|
---|
| 36 |
|
---|
| 37 | BEGIN {
|
---|
| 38 | @ISA = ('BasPlug');
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | sub new {
|
---|
| 42 | my ($class) = @_;
|
---|
[1244] | 43 | my $self = new BasPlug ("ArcPlug", @_);
|
---|
[4] | 44 |
|
---|
| 45 | return bless $self, $class;
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | # return 1 if this class might recurse using $pluginfo
|
---|
| 49 | sub is_recursive {
|
---|
| 50 | my $self = shift (@_);
|
---|
| 51 |
|
---|
| 52 | return 1;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
[317] | 55 | # return number of files processed, undef if can't process
|
---|
[4] | 56 | # Note that $base_dir might be "" and that $file might
|
---|
| 57 | # include directories
|
---|
| 58 | sub read {
|
---|
| 59 | my $self = shift (@_);
|
---|
[1244] | 60 | my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs) = @_;
|
---|
[1424] | 61 | my $outhandle = $self->{'outhandle'};
|
---|
[4] | 62 |
|
---|
[317] | 63 | my $count = 0;
|
---|
| 64 |
|
---|
[4] | 65 | # see if this has a archives information file within it
|
---|
[1244] | 66 | my $archive_info_filename = &util::filename_cat($base_dir,$file,"archives.inf");
|
---|
[4] | 67 |
|
---|
| 68 | if (-e $archive_info_filename) {
|
---|
| 69 |
|
---|
[317] | 70 | # found an archives.inf file
|
---|
[1424] | 71 | print $outhandle "ArcPlug: processing $archive_info_filename\n";
|
---|
[317] | 72 |
|
---|
[4] | 73 | # read in the archives information file
|
---|
| 74 | my $archive_info = new arcinfo ();
|
---|
| 75 | $archive_info->load_info ($archive_info_filename);
|
---|
| 76 |
|
---|
[230] | 77 | my $file_list = $archive_info->get_file_list();
|
---|
[4] | 78 |
|
---|
| 79 | # process each file
|
---|
[1244] | 80 | foreach my $subfile (@$file_list) {
|
---|
[809] | 81 | last if ($maxdocs != -1 && $count >= $maxdocs);
|
---|
[317] | 82 |
|
---|
[4] | 83 | my $tmp = &util::filename_cat ($file, $subfile->[0]);
|
---|
| 84 | next if $tmp eq $file;
|
---|
[317] | 85 | # note: metadata is not carried on to the next level
|
---|
| 86 | $count += &plugin::read ($pluginfo, $base_dir, $tmp, {}, $processor, $maxdocs);
|
---|
[4] | 87 | }
|
---|
| 88 |
|
---|
[317] | 89 | return $count;
|
---|
[4] | 90 | }
|
---|
| 91 |
|
---|
| 92 | # wasn't an archives directory, someone else will have to process it
|
---|
[317] | 93 | return undef;
|
---|
[4] | 94 | }
|
---|
| 95 |
|
---|
| 96 | 1;
|
---|