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

Last change on this file since 4842 was 4744, checked in by mdewsnip, 21 years ago

Tidied up and structures (representing the options of the plugin) in preparation for removing the print_usage() routines.

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