source: branches/New_Config_Format-branch/gsdl/perllib/plugins/ArcPlug.pm@ 1279

Last change on this file since 1279 was 1279, checked in by sjboddie, 24 years ago

merged changes to trunk into New_Config_Format branch

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
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
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
29
30package ArcPlug;
31
32use util;
33use BasPlug;
34use plugin;
35use arcinfo;
36
37BEGIN {
38 @ISA = ('BasPlug');
39}
40
41use strict;
42
43sub new {
44 my ($class) = @_;
45 my $self = new BasPlug ("ArcPlug", @_);
46
47 return bless $self, $class;
48}
49
50# return 1 if this class might recurse using $pluginfo
51sub is_recursive {
52 my $self = shift (@_);
53
54 return 1;
55}
56
57# return number of files processed, undef if can't process
58# Note that $base_dir might be "" and that $file might
59# include directories
60sub read {
61 my $self = shift (@_);
62 my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs) = @_;
63
64 my $count = 0;
65
66 # see if this has a archives information file within it
67 my $archive_info_filename = &util::filename_cat($base_dir,$file,"archives.inf");
68
69 if (-e $archive_info_filename) {
70
71 # found an archives.inf file
72 print STDERR "ArcPlug: processing $archive_info_filename\n";
73
74 # read in the archives information file
75 my $archive_info = new arcinfo ();
76 $archive_info->load_info ($archive_info_filename);
77
78 my $file_list = $archive_info->get_file_list();
79
80 # process each file
81 foreach my $subfile (@$file_list) {
82 last if ($maxdocs != -1 && $count >= $maxdocs);
83
84 my $tmp = &util::filename_cat ($file, $subfile->[0]);
85 next if $tmp eq $file;
86 # note: metadata is not carried on to the next level
87 $count += &plugin::read ($pluginfo, $base_dir, $tmp, {}, $processor, $maxdocs);
88 }
89
90 return $count;
91 }
92
93 # wasn't an archives directory, someone else will have to process it
94 return undef;
95}
96
971;
Note: See TracBrowser for help on using the repository browser.