Changeset 433
- Timestamp:
- 1999-08-04T17:23:41+12:00 (25 years ago)
- Location:
- trunk/gsdl
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/import.pl
r314 r433 27 27 print STDERR " -removeold Will remove the old contents of the archives\n"; 28 28 print STDERR " directory -- use with care\n"; 29 print STDERR " -gzip Use gzip to compress resulting gml documents\n"; 29 30 print STDERR " -maxdocs number Maximum number of documents to import\n\n"; 30 31 } … … 40 41 'keepold', \$keepold, 41 42 'removeold', \$removeold, 43 'gzip', \$gzip, 42 44 'maxdocs/\d+/', \$maxdocs)) { 43 45 &print_usage(); … … 110 112 111 113 # create a docsave object to process the documents 112 $processor = new docsave ($collection, $archive_info, $verbosity );114 $processor = new docsave ($collection, $archive_info, $verbosity, $gzip); 113 115 $processor->setarchivedir ($archivedir); 114 116 -
trunk/gsdl/perllib/docsave.pm
r170 r433 15 15 16 16 sub new { 17 my ($class, $collection, $archive_info, $verbosity ) = @_;17 my ($class, $collection, $archive_info, $verbosity, $gzip) = @_; 18 18 my $self = new docproc (); 19 19 … … 21 21 $self->{'archive_info'} = $archive_info; 22 22 $self->{'verbosity'} = $verbosity; 23 $self->{'gzip'} = $gzip; 23 24 24 25 # set a default for the archive directory … … 50 51 # same one. 51 52 $doc_dir = $doc_info->[0]; 52 $doc_dir =~ s/\/?doc\.gml $//;53 $doc_dir =~ s/\/?doc\.gml(\.gz)?$//; 53 54 54 55 } else { … … 63 64 } 64 65 } while ($doc_dir_rest ne "" && 65 ( -d "$archive_dir/$doc_dir.dir"||66 ((-d &util::filename_cat ($archive_dir, "$doc_dir.dir")) || 66 67 ($self->{'archive_info'}->size() >= 1024 && $doc_dir_num < 2))); 67 68 $doc_dir .= ".dir"; … … 75 76 foreach $assoc_file (@{$doc_obj->get_assoc_files()}) { 76 77 if (-e $assoc_file->[0]) { 77 &util::cp ($assoc_file->[0], "$archive_dir/$doc_dir/$assoc_file->[1]"); 78 my $afile = &util::filename_cat($archive_dir, $doc_dir, $assoc_file->[1]); 79 &util::cp ($assoc_file->[0], $afile); 78 80 $doc_obj->add_metadata ($doc_obj->get_top_section(), 79 81 "gsdlassocfile", … … 81 83 } else { 82 84 print STDERR "docsave::process couldn't copy the associated file " . 83 "$assoc_file->[0] to $a rchive_dir/$doc_dir/$assoc_file->[1]\n"85 "$assoc_file->[0] to $afile\n"; 84 86 } 85 87 } 86 88 87 89 # save this document 88 if (!open (OUTDOC, ">$archive_dir/$doc_dir/doc.gml")) { 89 print STDERR "docsave::process could not write to file " . 90 "$archive_dir/$doc_dir/doc.gml\n"; 90 my $doc_file = &util::filename_cat ($archive_dir, $doc_dir, "doc.gml"); 91 my $short_doc_file = &util::filename_cat ($doc_dir, "doc.gml"); 92 93 if (!open (OUTDOC, ">$doc_file")) { 94 print STDERR "docsave::process could not write to file $docfile\n"; 91 95 return; 92 96 } … … 94 98 close OUTDOC; 95 99 100 if ($self->{'gzip'}) { 101 `gzip $doc_file`; 102 $doc_file .= ".gz"; 103 $short_doc_file .= ".gz"; 104 if (!-e $doc_file) { 105 print STDERR "error while gzipping: $doc_file doesn't exist\n"; 106 return; 107 } 108 } 109 96 110 # store reference in the archive_info 97 $self->{'archive_info'}->add_info($OID, 98 "$doc_dir/doc.gml"); 111 $self->{'archive_info'}->add_info($OID, $short_doc_file); 99 112 100 113 } -
trunk/gsdl/perllib/plugins/GMLPlug.pm
r317 r433 47 47 48 48 # see if this is a gml book 49 return undef unless (-f $fullname && $fullname =~ /\.gml $/i);49 return undef unless (-f $fullname && $fullname =~ /\.gml(\.gz)?$/i); 50 50 51 my ($parent_dir) = $fullname =~ /^(.*)\/[^\/]+.gml$/; 51 my ($parent_dir, $gz) = $fullname =~ /^(.*)\/[^\/]+.gml(\.gz)?$/i; 52 53 if (defined $gz && $gz =~ /\.gz/i) { 54 $gz = 1; 55 } else { 56 $gz = 0; 57 } 52 58 53 59 # create a new document … … 60 66 my $gml = ""; 61 67 my $line = ""; 62 if (!open (INFILE, $fullname)) { 63 print STDERR "GMLPlug::read - couldn't read $fullname\n"; 64 return undef; 68 69 if ($gz) { 70 if (!open (INFILE, "zcat $fullname |")) { 71 print STDERR "GMLPlug::read - zcat couldn't read $fullname\n"; 72 return undef; 73 } 74 } else { 75 if (!open (INFILE, $fullname)) { 76 print STDERR "GMLPlug::read - couldn't read $fullname\n"; 77 return undef; 78 } 65 79 } 80 66 81 while (defined ($line = <INFILE>)) { 67 82 $gml .= $line;
Note:
See TracChangeset
for help on using the changeset viewer.