diff options
Diffstat (limited to 'cpan/IO-Compress/lib/IO/Uncompress')
-rw-r--r-- | cpan/IO-Compress/lib/IO/Uncompress/Adapter/Bunzip2.pm | 6 | ||||
-rw-r--r-- | cpan/IO-Compress/lib/IO/Uncompress/Adapter/Identity.pm | 6 | ||||
-rw-r--r-- | cpan/IO-Compress/lib/IO/Uncompress/Adapter/Inflate.pm | 6 | ||||
-rw-r--r-- | cpan/IO-Compress/lib/IO/Uncompress/AnyInflate.pm | 18 | ||||
-rw-r--r-- | cpan/IO-Compress/lib/IO/Uncompress/AnyUncompress.pm | 34 | ||||
-rw-r--r-- | cpan/IO-Compress/lib/IO/Uncompress/Base.pm | 6 | ||||
-rw-r--r-- | cpan/IO-Compress/lib/IO/Uncompress/Bunzip2.pm | 10 | ||||
-rw-r--r-- | cpan/IO-Compress/lib/IO/Uncompress/Gunzip.pm | 14 | ||||
-rw-r--r-- | cpan/IO-Compress/lib/IO/Uncompress/Inflate.pm | 8 | ||||
-rw-r--r-- | cpan/IO-Compress/lib/IO/Uncompress/RawInflate.pm | 10 | ||||
-rw-r--r-- | cpan/IO-Compress/lib/IO/Uncompress/Unzip.pm | 100 |
11 files changed, 129 insertions, 89 deletions
diff --git a/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Bunzip2.pm b/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Bunzip2.pm index a3253654b9..913a0a780b 100644 --- a/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Bunzip2.pm +++ b/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Bunzip2.pm @@ -4,12 +4,12 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.027 qw(:Status); +use IO::Compress::Base::Common 2.030 qw(:Status); -use Compress::Raw::Bzip2 2.027 ; +use Compress::Raw::Bzip2 2.030 ; our ($VERSION, @ISA); -$VERSION = '2.027'; +$VERSION = '2.030'; sub mkUncompObject { diff --git a/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Identity.pm b/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Identity.pm index 2ba1a6266f..c4671dc5cc 100644 --- a/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Identity.pm +++ b/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Identity.pm @@ -4,13 +4,13 @@ use warnings; use strict; use bytes; -use IO::Compress::Base::Common 2.027 qw(:Status); +use IO::Compress::Base::Common 2.030 qw(:Status); our ($VERSION); -$VERSION = '2.027'; +$VERSION = '2.030'; -use Compress::Raw::Zlib 2.027 (); +use Compress::Raw::Zlib 2.030 (); sub mkUncompObject { diff --git a/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Inflate.pm b/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Inflate.pm index 4dffd666f2..19788521de 100644 --- a/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Inflate.pm +++ b/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Inflate.pm @@ -4,11 +4,11 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.027 qw(:Status); -use Compress::Raw::Zlib 2.027 qw(Z_OK Z_BUF_ERROR Z_STREAM_END Z_FINISH MAX_WBITS); +use IO::Compress::Base::Common 2.030 qw(:Status); +use Compress::Raw::Zlib 2.030 qw(Z_OK Z_BUF_ERROR Z_STREAM_END Z_FINISH MAX_WBITS); our ($VERSION); -$VERSION = '2.027'; +$VERSION = '2.030'; diff --git a/cpan/IO-Compress/lib/IO/Uncompress/AnyInflate.pm b/cpan/IO-Compress/lib/IO/Uncompress/AnyInflate.pm index 0d01f7b9cf..37d2b167e6 100644 --- a/cpan/IO-Compress/lib/IO/Uncompress/AnyInflate.pm +++ b/cpan/IO-Compress/lib/IO/Uncompress/AnyInflate.pm @@ -6,22 +6,22 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.027 qw(createSelfTiedObject); +use IO::Compress::Base::Common 2.030 qw(createSelfTiedObject); -use IO::Uncompress::Adapter::Inflate 2.027 (); +use IO::Uncompress::Adapter::Inflate 2.030 (); -use IO::Uncompress::Base 2.027 ; -use IO::Uncompress::Gunzip 2.027 ; -use IO::Uncompress::Inflate 2.027 ; -use IO::Uncompress::RawInflate 2.027 ; -use IO::Uncompress::Unzip 2.027 ; +use IO::Uncompress::Base 2.030 ; +use IO::Uncompress::Gunzip 2.030 ; +use IO::Uncompress::Inflate 2.030 ; +use IO::Uncompress::RawInflate 2.030 ; +use IO::Uncompress::Unzip 2.030 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $AnyInflateError); -$VERSION = '2.027'; +$VERSION = '2.030'; $AnyInflateError = ''; @ISA = qw( Exporter IO::Uncompress::Base ); @@ -48,7 +48,7 @@ sub anyinflate sub getExtraParams { - use IO::Compress::Base::Common 2.027 qw(:Parse); + use IO::Compress::Base::Common 2.030 qw(:Parse); return ( 'RawInflate' => [1, 1, Parse_boolean, 0] ) ; } diff --git a/cpan/IO-Compress/lib/IO/Uncompress/AnyUncompress.pm b/cpan/IO-Compress/lib/IO/Uncompress/AnyUncompress.pm index 206a0ed86a..c7d503152a 100644 --- a/cpan/IO-Compress/lib/IO/Uncompress/AnyUncompress.pm +++ b/cpan/IO-Compress/lib/IO/Uncompress/AnyUncompress.pm @@ -4,16 +4,16 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.027 qw(createSelfTiedObject); +use IO::Compress::Base::Common 2.030 qw(createSelfTiedObject); -use IO::Uncompress::Base 2.027 ; +use IO::Uncompress::Base 2.030 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $AnyUncompressError); -$VERSION = '2.027'; +$VERSION = '2.030'; $AnyUncompressError = ''; @ISA = qw( Exporter IO::Uncompress::Base ); @@ -27,22 +27,22 @@ Exporter::export_ok_tags('all'); BEGIN { - eval ' use IO::Uncompress::Adapter::Inflate 2.027 ;'; - eval ' use IO::Uncompress::Adapter::Bunzip2 2.027 ;'; - eval ' use IO::Uncompress::Adapter::LZO 2.027 ;'; - eval ' use IO::Uncompress::Adapter::Lzf 2.027 ;'; + eval ' use IO::Uncompress::Adapter::Inflate 2.030 ;'; + eval ' use IO::Uncompress::Adapter::Bunzip2 2.030 ;'; + eval ' use IO::Uncompress::Adapter::LZO 2.030 ;'; + eval ' use IO::Uncompress::Adapter::Lzf 2.030 ;'; eval ' use IO::Uncompress::Adapter::UnLzma 2.020 ;'; eval ' use IO::Uncompress::Adapter::UnXz 2.020 ;'; - eval ' use IO::Uncompress::Bunzip2 2.027 ;'; - eval ' use IO::Uncompress::UnLzop 2.027 ;'; - eval ' use IO::Uncompress::Gunzip 2.027 ;'; - eval ' use IO::Uncompress::Inflate 2.027 ;'; - eval ' use IO::Uncompress::RawInflate 2.027 ;'; - eval ' use IO::Uncompress::Unzip 2.027 ;'; - eval ' use IO::Uncompress::UnLzf 2.027 ;'; - eval ' use IO::Uncompress::UnLzma 2.027 ;'; - eval ' use IO::Uncompress::UnXz 2.027 ;'; + eval ' use IO::Uncompress::Bunzip2 2.030 ;'; + eval ' use IO::Uncompress::UnLzop 2.030 ;'; + eval ' use IO::Uncompress::Gunzip 2.030 ;'; + eval ' use IO::Uncompress::Inflate 2.030 ;'; + eval ' use IO::Uncompress::RawInflate 2.030 ;'; + eval ' use IO::Uncompress::Unzip 2.030 ;'; + eval ' use IO::Uncompress::UnLzf 2.030 ;'; + eval ' use IO::Uncompress::UnLzma 2.030 ;'; + eval ' use IO::Uncompress::UnXz 2.030 ;'; } sub new @@ -60,7 +60,7 @@ sub anyuncompress sub getExtraParams { - use IO::Compress::Base::Common 2.027 qw(:Parse); + use IO::Compress::Base::Common 2.030 qw(:Parse); return ( 'RawInflate' => [1, 1, Parse_boolean, 0] , 'UnLzma' => [1, 1, Parse_boolean, 0] ) ; } diff --git a/cpan/IO-Compress/lib/IO/Uncompress/Base.pm b/cpan/IO-Compress/lib/IO/Uncompress/Base.pm index e73bb9d83b..2814163e2f 100644 --- a/cpan/IO-Compress/lib/IO/Uncompress/Base.pm +++ b/cpan/IO-Compress/lib/IO/Uncompress/Base.pm @@ -9,12 +9,12 @@ our (@ISA, $VERSION, @EXPORT_OK, %EXPORT_TAGS); @ISA = qw(Exporter IO::File); -$VERSION = '2.027'; +$VERSION = '2.030'; use constant G_EOF => 0 ; use constant G_ERR => -1 ; -use IO::Compress::Base::Common 2.027 ; +use IO::Compress::Base::Common 2.030 ; #use Parse::Parameters ; use IO::File ; @@ -980,7 +980,7 @@ sub gotoNextStream #*$self->{EndStream} = 0 ; if ( ! defined $magic) { - if (! *$self->{Transparent} ) + if (! *$self->{Transparent} || $self->eof()) { *$self->{EndStream} = 1 ; return 0; diff --git a/cpan/IO-Compress/lib/IO/Uncompress/Bunzip2.pm b/cpan/IO-Compress/lib/IO/Uncompress/Bunzip2.pm index a96c0235e7..288ead181c 100644 --- a/cpan/IO-Compress/lib/IO/Uncompress/Bunzip2.pm +++ b/cpan/IO-Compress/lib/IO/Uncompress/Bunzip2.pm @@ -4,15 +4,15 @@ use strict ; use warnings; use bytes; -use IO::Compress::Base::Common 2.027 qw(:Status createSelfTiedObject); +use IO::Compress::Base::Common 2.030 qw(:Status createSelfTiedObject); -use IO::Uncompress::Base 2.027 ; -use IO::Uncompress::Adapter::Bunzip2 2.027 ; +use IO::Uncompress::Base 2.030 ; +use IO::Uncompress::Adapter::Bunzip2 2.030 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $Bunzip2Error); -$VERSION = '2.027'; +$VERSION = '2.030'; $Bunzip2Error = ''; @ISA = qw( Exporter IO::Uncompress::Base ); @@ -40,7 +40,7 @@ sub getExtraParams { my $self = shift ; - use IO::Compress::Base::Common 2.027 qw(:Parse); + use IO::Compress::Base::Common 2.030 qw(:Parse); return ( 'Verbosity' => [1, 1, Parse_boolean, 0], diff --git a/cpan/IO-Compress/lib/IO/Uncompress/Gunzip.pm b/cpan/IO-Compress/lib/IO/Uncompress/Gunzip.pm index d13514101d..4b10f4bb28 100644 --- a/cpan/IO-Compress/lib/IO/Uncompress/Gunzip.pm +++ b/cpan/IO-Compress/lib/IO/Uncompress/Gunzip.pm @@ -9,12 +9,12 @@ use strict ; use warnings; use bytes; -use IO::Uncompress::RawInflate 2.027 ; +use IO::Uncompress::RawInflate 2.030 ; -use Compress::Raw::Zlib 2.027 qw( crc32 ) ; -use IO::Compress::Base::Common 2.027 qw(:Status createSelfTiedObject); -use IO::Compress::Gzip::Constants 2.027 ; -use IO::Compress::Zlib::Extra 2.027 ; +use Compress::Raw::Zlib 2.030 qw( crc32 ) ; +use IO::Compress::Base::Common 2.030 qw(:Status createSelfTiedObject); +use IO::Compress::Gzip::Constants 2.030 ; +use IO::Compress::Zlib::Extra 2.030 ; require Exporter ; @@ -28,7 +28,7 @@ Exporter::export_ok_tags('all'); $GunzipError = ''; -$VERSION = '2.027'; +$VERSION = '2.030'; sub new { @@ -47,7 +47,7 @@ sub gunzip sub getExtraParams { - use IO::Compress::Base::Common 2.027 qw(:Parse); + use IO::Compress::Base::Common 2.030 qw(:Parse); return ( 'ParseExtra' => [1, 1, Parse_boolean, 0] ) ; } diff --git a/cpan/IO-Compress/lib/IO/Uncompress/Inflate.pm b/cpan/IO-Compress/lib/IO/Uncompress/Inflate.pm index 86abb50d60..27c1d8584d 100644 --- a/cpan/IO-Compress/lib/IO/Uncompress/Inflate.pm +++ b/cpan/IO-Compress/lib/IO/Uncompress/Inflate.pm @@ -5,15 +5,15 @@ use strict ; use warnings; use bytes; -use IO::Compress::Base::Common 2.027 qw(:Status createSelfTiedObject); -use IO::Compress::Zlib::Constants 2.027 ; +use IO::Compress::Base::Common 2.030 qw(:Status createSelfTiedObject); +use IO::Compress::Zlib::Constants 2.030 ; -use IO::Uncompress::RawInflate 2.027 ; +use IO::Uncompress::RawInflate 2.030 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $InflateError); -$VERSION = '2.027'; +$VERSION = '2.030'; $InflateError = ''; @ISA = qw( Exporter IO::Uncompress::RawInflate ); diff --git a/cpan/IO-Compress/lib/IO/Uncompress/RawInflate.pm b/cpan/IO-Compress/lib/IO/Uncompress/RawInflate.pm index 609928fd4e..12e915b625 100644 --- a/cpan/IO-Compress/lib/IO/Uncompress/RawInflate.pm +++ b/cpan/IO-Compress/lib/IO/Uncompress/RawInflate.pm @@ -5,16 +5,16 @@ use strict ; use warnings; use bytes; -use Compress::Raw::Zlib 2.027 ; -use IO::Compress::Base::Common 2.027 qw(:Status createSelfTiedObject); +use Compress::Raw::Zlib 2.030 ; +use IO::Compress::Base::Common 2.030 qw(:Status createSelfTiedObject); -use IO::Uncompress::Base 2.027 ; -use IO::Uncompress::Adapter::Inflate 2.027 ; +use IO::Uncompress::Base 2.030 ; +use IO::Uncompress::Adapter::Inflate 2.030 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, %DEFLATE_CONSTANTS, $RawInflateError); -$VERSION = '2.027'; +$VERSION = '2.030'; $RawInflateError = ''; @ISA = qw( Exporter IO::Uncompress::Base ); diff --git a/cpan/IO-Compress/lib/IO/Uncompress/Unzip.pm b/cpan/IO-Compress/lib/IO/Uncompress/Unzip.pm index 17cc78d7b6..fe75213231 100644 --- a/cpan/IO-Compress/lib/IO/Uncompress/Unzip.pm +++ b/cpan/IO-Compress/lib/IO/Uncompress/Unzip.pm @@ -8,14 +8,14 @@ use strict ; use warnings; use bytes; -use IO::Uncompress::RawInflate 2.027 ; -use IO::Compress::Base::Common 2.027 qw(:Status createSelfTiedObject); -use IO::Uncompress::Adapter::Inflate 2.027 ; -use IO::Uncompress::Adapter::Identity 2.027 ; -use IO::Compress::Zlib::Extra 2.027 ; -use IO::Compress::Zip::Constants 2.027 ; +use IO::Uncompress::RawInflate 2.030 ; +use IO::Compress::Base::Common 2.030 qw(:Status createSelfTiedObject); +use IO::Uncompress::Adapter::Inflate 2.030 ; +use IO::Uncompress::Adapter::Identity 2.030 ; +use IO::Compress::Zlib::Extra 2.030 ; +use IO::Compress::Zip::Constants 2.030 ; -use Compress::Raw::Zlib 2.027 qw(crc32) ; +use Compress::Raw::Zlib 2.030 qw(crc32) ; BEGIN { @@ -30,7 +30,7 @@ require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $UnzipError, %headerLookup); -$VERSION = '2.027'; +$VERSION = '2.030'; $UnzipError = ''; @ISA = qw(Exporter IO::Uncompress::RawInflate); @@ -63,7 +63,7 @@ sub unzip sub getExtraParams { - use IO::Compress::Base::Common 2.027 qw(:Parse); + use IO::Compress::Base::Common 2.030 qw(:Parse); return ( @@ -1056,54 +1056,57 @@ C<InputLength> option. =head2 Examples -To read the contents of the file C<file1.txt.zip> and write the -uncompressed data to the file C<file1.txt>. +Say you have a zip file, C<file1.zip>, that only contains a +single member, you can read it and write the uncompressed data to the +file C<file1.txt> like this. use strict ; use warnings ; use IO::Uncompress::Unzip qw(unzip $UnzipError) ; - my $input = "file1.txt.zip"; + my $input = "file1.zip"; my $output = "file1.txt"; unzip $input => $output or die "unzip failed: $UnzipError\n"; -To read from an existing Perl filehandle, C<$input>, and write the -uncompressed data to a buffer, C<$buffer>. +If you have a zip file that contains multiple members and want to read a +specific member from the file, say C<"data1">, use the C<Name> option use strict ; use warnings ; use IO::Uncompress::Unzip qw(unzip $UnzipError) ; - use IO::File ; - my $input = new IO::File "<file1.txt.zip" - or die "Cannot open 'file1.txt.zip': $!\n" ; - my $buffer ; - unzip $input => \$buffer + my $input = "file1.zip"; + my $output = "file1.txt"; + unzip $input => $output, Name => "data1" or die "unzip failed: $UnzipError\n"; -To uncompress all files in the directory "/my/home" that match "*.txt.zip" and store the compressed data in the same directory +Alternatively, if you want to read the C<"data1"> member into memory, use +a scalar reference for the C<output> partameter. use strict ; use warnings ; use IO::Uncompress::Unzip qw(unzip $UnzipError) ; - unzip '</my/home/*.txt.zip>' => '</my/home/#1.txt>' + my $input = "file1.zip"; + my $output ; + unzip $input => \$output, Name => "data1" or die "unzip failed: $UnzipError\n"; + # $output now contains the uncompressed data -and if you want to compress each file one at a time, this will do the trick +To read from an existing Perl filehandle, C<$input>, and write the +uncompressed data to a buffer, C<$buffer>. use strict ; use warnings ; use IO::Uncompress::Unzip qw(unzip $UnzipError) ; + use IO::File ; - for my $input ( glob "/my/home/*.txt.zip" ) - { - my $output = $input; - $output =~ s/.zip// ; - unzip $input => $output - or die "Error compressing '$input': $UnzipError\n"; - } + my $input = new IO::File "<file1.zip" + or die "Cannot open 'file1.zip': $!\n" ; + my $buffer ; + unzip $input => \$buffer + or die "unzip failed: $UnzipError\n"; =head1 OO Interface @@ -1165,7 +1168,7 @@ OPTS is a combination of the following options: =item C<< Name => "membername" >> -Create "membername" in the zip file. +Open "membername" from the zip file for reading. =item C<< AutoClose => 0|1 >> @@ -1513,6 +1516,43 @@ Same as doing this See L<IO::Uncompress::Unzip::FAQ|IO::Uncompress::Unzip::FAQ/"Compressed files and Net::FTP"> +=head2 Walking through a zip file + +The code below can be used to traverse a zip file, one compressed data +stream at a time. + + use IO::Uncompress::Unzip qw($UnzipError); + + my $zipfile = "somefile.zip"; + my $u = new IO::Uncompress::Unzip $zipfile + or die "Cannot open $zipfile: $UnzipError"; + + my $status; + for ($status = 1; ! $u->eof(); $status = $u->nextStream()) + { + + my $name = $u->getHeaderInfo()->{Name}; + warn "Processing member $name\n" ; + + my $buff; + while (($status = $u->read($buff)) > 0) { + # Do something here + } + + last if $status < 0; + } + + die "Error processing $zipfile: $!\n" + if $status < 0 ; + +Each individual compressed data stream is read until the logical +end-of-file is reached. Then C<nextStream> is called. This will skip to the +start of the next compressed data stream and clear the end-of-file flag. + +It is also worth noting that C<nextStream> can be called at any time -- you +don't have to wait until you have exhausted a compressed data stream before +skipping to the next one. + =head1 SEE ALSO L<Compress::Zlib>, L<IO::Compress::Gzip>, L<IO::Uncompress::Gunzip>, L<IO::Compress::Deflate>, L<IO::Uncompress::Inflate>, L<IO::Compress::RawDeflate>, L<IO::Uncompress::RawInflate>, L<IO::Compress::Bzip2>, L<IO::Uncompress::Bunzip2>, L<IO::Compress::Lzma>, L<IO::Uncompress::UnLzma>, L<IO::Compress::Xz>, L<IO::Uncompress::UnXz>, L<IO::Compress::Lzop>, L<IO::Uncompress::UnLzop>, L<IO::Compress::Lzf>, L<IO::Uncompress::UnLzf>, L<IO::Uncompress::AnyInflate>, L<IO::Uncompress::AnyUncompress> |