- Timestamp:
- 09/22/05 13:34:56 (19 years ago)
- Location:
- trunk/soft/ObsData/ObsData
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/soft/ObsData/ObsData/Archive.pm
- Property cvs2svn:cvs-rev changed from 1.3 to 1.4
r7 r8 7 7 use File::Copy; 8 8 use File::Temp qw/ tempfile /; 9 use ObsData::Archive::Compressed; 9 10 10 11 sub new { … … 20 21 21 22 for ($archive) { 22 /\. gz$/ and do {23 /\.(gz|bz2|Z)$/ and do { 23 24 $beclass = 'Compressed'; 24 $options{uncomp} = 'gzip -dc';25 last;26 };27 /\.bz2$/ and do {28 $beclass = 'Compressed';29 $options{uncomp} = 'bzip2 -dc';30 25 last; 31 26 }; … … 34 29 if ($beclass) { 35 30 my $obj; 36 eval("require $class\:\:$beclass;");31 # eval("require $class\:\:$beclass;"); 37 32 eval("\$obj = $class\:\:$beclass->new(\$o);"); 38 33 return $obj; -
trunk/soft/ObsData/ObsData/Archive/Compressed.pm
- Property cvs2svn:cvs-rev changed from 1.1 to 1.2
r7 r8 1 1 # $Id$ 2 2 3 package ObsData::Archive:: Gzip;3 package ObsData::Archive::Compressed; 4 4 5 5 use strict; 6 6 use warnings; 7 use File::Copy; 8 use File::Temp qw/ tempfile /; 7 9 8 10 our @ISA = qw(ObsData::Archive); 9 11 10 12 sub new { 11 my ($class, %options) = @_;13 my ($class, $options) = @_; 12 14 13 bless(\%options, $class); 15 if (!$options->{uncomp}) { 16 for ($options->{archive}) { 17 /\.(Z|gz)$/ and $options->{uncomp} = 'gzip -dc'; 18 /\.bz2$/ and $options->{uncomp} = 'bzip2 -dc'; 19 } 20 } 21 22 bless($options, $class); 14 23 } 15 24 … … 20 29 sub ls { 21 30 my ($self) = @_; 22 my ($file) = $self->{archive} =~ m!^(?:.*/)?(.*)(?:\.gz)?!;23 return $ file;31 $self->{archive} =~ m,^(?:.*/)?(?:(.*)(?:\.(?:gz|bz2|Z))|(.*))$,; 32 return $1 || $2; 24 33 } 25 34 … … 41 50 } 42 51 43 open(my $sourcefh, " gzip -dc'$self->{archive}' |") or return undef;52 open(my $sourcefh, "$self->{uncomp} '$self->{archive}' |") or return undef; 44 53 45 54 if(!copy($sourcefh, $fh)) {
Note: See TracChangeset
for help on using the changeset viewer.