- Timestamp:
- 09/21/05 13:21:13 (19 years ago)
- Location:
- trunk/soft/ObsData
- Files:
-
- 5 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/soft/ObsData/ObsData/Archive.pm
- Property cvs2svn:cvs-rev changed from 1.1 to 1.2
r4 r5 5 5 use strict; 6 6 use warnings; 7 use File::Copy; 8 use File::Temp qw/ tempfile /; 7 9 8 10 sub new { … … 28 30 } 29 31 32 sub DESTROY { 33 my ($self) = @_; 34 } 35 30 36 sub ls { 31 37 my ($self) = @_; 32 my ($file) = $self->{archive} =~ m!^( :?.*/)?(.*)!;38 my ($file) = $self->{archive} =~ m!^(?:.*/)?(.*)!; 33 39 return $file; 40 } 41 42 sub extract { 43 my ($self, $file, $dest) = @_; 44 # the devel should specify the file he want 45 # as the basic contains only 1 file... this does not matter 46 47 my ($fh, $fname); 48 49 if ($dest) { 50 $fname = $dest; 51 open($fh, '>', $dest) or return undef; 52 } else { 53 ($fh, $fname) = tempfile( 54 DIR => $self->_tempdir, 55 UNLINK => 1, 56 ) or return undef; 57 } 58 59 if(!copy($self->{archive}, $fh)) { 60 unlink($fname); 61 return undef; 62 } 63 64 close($fh); 65 $fname 66 } 67 68 ### Private method 69 70 sub _tempdir { 71 my ($self) = @_; 72 $self->{tmpdir} || $ENV{TMPDIR} 34 73 } 35 74 … … 48 87 list the content of the archive 49 88 89 =item extract 90 91 Extract a file from the archive and return the filename of extract file
Note: See TracChangeset
for help on using the changeset viewer.