diff options
author | Steve Peters <steve@fisharerojo.org> | 2007-03-04 07:01:34 +0000 |
---|---|---|
committer | Steve Peters <steve@fisharerojo.org> | 2007-03-04 07:01:34 +0000 |
commit | 4e7676c784119f034a642411bdc4cde7d6f0c54a (patch) | |
tree | c7c308dae5889d0b6fa16128d78af779c9f99eaa /ext/IO | |
parent | ed94752d3e14e57ddb49df6f1f1d23eb25daf7af (diff) | |
download | perl-4e7676c784119f034a642411bdc4cde7d6f0c54a.tar.gz |
Upgrade to IO-Compress-Base-2.004, Compress-Raw-Zlib-2.004,
IO-Compress-Zlib-2.004, and Compress-Zlib-2.004.
p4raw-id: //depot/perl@30458
Diffstat (limited to 'ext/IO')
28 files changed, 278 insertions, 174 deletions
diff --git a/ext/IO/Compress/Base/Changes b/ext/IO/Compress/Base/Changes index f7357f1832..24e88f0616 100644 --- a/ext/IO/Compress/Base/Changes +++ b/ext/IO/Compress/Base/Changes @@ -1,6 +1,10 @@ CHANGES ------- + 2.004 3 March 2007 + + * Made seek less wasteful of memory. + 2.003 2 January 2007 * Added explicit version checking diff --git a/ext/IO/Compress/Base/Makefile.PL b/ext/IO/Compress/Base/Makefile.PL index 3b5518f396..751538a571 100644 --- a/ext/IO/Compress/Base/Makefile.PL +++ b/ext/IO/Compress/Base/Makefile.PL @@ -35,6 +35,9 @@ WriteMakefile( : () ), + ((ExtUtils::MakeMaker->VERSION() gt '6.30') ? + ('LICENSE' => 'perl') : ()), + ) ; # end of file Makefile.PL diff --git a/ext/IO/Compress/Base/README b/ext/IO/Compress/Base/README index ba41fd0314..1e557c97e6 100644 --- a/ext/IO/Compress/Base/README +++ b/ext/IO/Compress/Base/README @@ -1,9 +1,9 @@ IO::Compress::Base - Version 2.003 + Version 2.004 - 2nd January 2007 + 3rd March 2007 Copyright (c) 2005-2007 Paul Marquess. All rights reserved. diff --git a/ext/IO/Compress/Base/lib/IO/Compress/Base.pm b/ext/IO/Compress/Base/lib/IO/Compress/Base.pm index 47f26ef386..8617b5630f 100644 --- a/ext/IO/Compress/Base/lib/IO/Compress/Base.pm +++ b/ext/IO/Compress/Base/lib/IO/Compress/Base.pm @@ -6,7 +6,7 @@ require 5.004 ; use strict ; use warnings; -use IO::Compress::Base::Common 2.003 ; +use IO::Compress::Base::Common 2.004 ; use IO::File ; use Scalar::Util qw(blessed readonly); @@ -17,22 +17,13 @@ use Carp ; use Symbol; use bytes; -our (@ISA, $VERSION, $got_encode); +our (@ISA, $VERSION); #@ISA = qw(Exporter IO::File); -$VERSION = '2.003'; +$VERSION = '2.004'; #Can't locate object method "SWASHNEW" via package "utf8" (perhaps you forgot to load "utf8"?) at .../ext/Compress-Zlib/Gzip/blib/lib/Compress/Zlib/Common.pm line 16. -#$got_encode = 0; -#eval -#{ -# require Encode; -# Encode->import('encode', 'find_encoding'); -#}; -# -#$got_encode = 1 unless $@; - sub saveStatus { my $self = shift ; @@ -157,7 +148,7 @@ sub checkParams { # Generic Parameters 'AutoClose' => [1, 1, Parse_boolean, 0], - #'Encoding' => [1, 1, Parse_any, undef], + #'Encode' => [1, 1, Parse_any, undef], 'Strict' => [0, 1, Parse_boolean, 1], 'Append' => [1, 1, Parse_boolean, 0], 'BinModeIn' => [1, 1, Parse_boolean, 0], @@ -229,19 +220,10 @@ sub _create -# TODO - encoding -# if ($got->parsed('Encoding')) { -# $obj->croakError("$class: Encode module needed to use -Encoding") -# if ! $got_encode; -# -# my $want_encoding = $got->value('Encoding'); -# my $encoding = find_encoding($want_encoding); -# -# $obj->croakError("$class: Encoding '$want_encoding' is not available") -# if ! $encoding; -# -# *$obj->{Encoding} = $encoding; -# } + if ($got->parsed('Encode')) { + my $want_encoding = $got->value('Encode'); + *$obj->{Encoding} = getEncoding($obj, $class, $want_encoding); + } $obj->ckParams($got) or $obj->croakError("${class}: " . $obj->error()); @@ -616,14 +598,14 @@ sub syswrite return 0 if ! defined $$buffer || length $$buffer == 0 ; - my $buffer_length = defined $$buffer ? length($$buffer) : 0 ; - *$self->{UnCompSize}->add($buffer_length) ; + if (*$self->{Encoding}) { + $$buffer = *$self->{Encoding}->encode($$buffer); + } $self->filterUncompressed($buffer); -# if (*$self->{Encoding}) { -# $$buffer = *$self->{Encoding}->encode($$buffer); -# } + my $buffer_length = defined $$buffer ? length($$buffer) : 0 ; + *$self->{UnCompSize}->add($buffer_length) ; my $outBuffer=''; my $status = *$self->{Compress}->compr($buffer, $outBuffer) ; diff --git a/ext/IO/Compress/Base/lib/IO/Compress/Base/Common.pm b/ext/IO/Compress/Base/lib/IO/Compress/Base/Common.pm index dc772a894a..9c0b6fd880 100644 --- a/ext/IO/Compress/Base/lib/IO/Compress/Base/Common.pm +++ b/ext/IO/Compress/Base/lib/IO/Compress/Base/Common.pm @@ -9,15 +9,16 @@ use Scalar::Util qw(blessed readonly); use File::GlobMapper; require Exporter; -our ($VERSION, @ISA, @EXPORT, %EXPORT_TAGS); +our ($VERSION, @ISA, @EXPORT, %EXPORT_TAGS, $HAS_ENCODE); @ISA = qw(Exporter); -$VERSION = '2.003'; +$VERSION = '2.004'; @EXPORT = qw( isaFilehandle isaFilename whatIsInput whatIsOutput isaFileGlobString cleanFileGlobString oneTarget setBinModeInput setBinModeOutput ckInOutParams createSelfTiedObject + getEncoding WANT_CODE WANT_EXT @@ -41,11 +42,39 @@ use constant STATUS_OK => 0; use constant STATUS_ENDSTREAM => 1; use constant STATUS_EOF => 2; use constant STATUS_ERROR => -1; -#use constant STATUS_OK => 0; -#use constant STATUS_ENDSTREAM => 1; -#use constant STATUS_ERROR => 2; -#use constant STATUS_EOF => 3; +sub hasEncode() +{ + if (! defined $HAS_ENCODE) { + eval + { + require Encode; + Encode->import(); + }; + + $HAS_ENCODE = $@ ? 0 : 1 ; + } + + return $HAS_ENCODE; +} + +sub getEncoding($$$) +{ + my $obj = shift; + my $class = shift ; + my $want_encoding = shift ; + + $obj->croakError("$class: Encode module needed to use -Encode") + if ! hasEncode(); + + my $encoding = Encode::find_encoding($want_encoding); + + $obj->croakError("$class: Encoding '$want_encoding' is not available") + if ! $encoding; + + return $encoding; +} + our ($needBinmode); $needBinmode = ($^O eq 'MSWin32' || ($] >= 5.006 && eval ' ${^UNICODE} || ${^UTF8LOCALE} ')) diff --git a/ext/IO/Compress/Base/lib/IO/Uncompress/AnyUncompress.pm b/ext/IO/Compress/Base/lib/IO/Uncompress/AnyUncompress.pm index 8657c188bd..923aa839c5 100644 --- a/ext/IO/Compress/Base/lib/IO/Uncompress/AnyUncompress.pm +++ b/ext/IO/Compress/Base/lib/IO/Uncompress/AnyUncompress.pm @@ -4,16 +4,16 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.003 qw(createSelfTiedObject); +use IO::Compress::Base::Common 2.004 qw(createSelfTiedObject); -use IO::Uncompress::Base 2.003 ; +use IO::Uncompress::Base 2.004 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $AnyUncompressError); -$VERSION = '2.003'; +$VERSION = '2.004'; $AnyUncompressError = ''; @ISA = qw( Exporter IO::Uncompress::Base ); @@ -27,18 +27,18 @@ Exporter::export_ok_tags('all'); BEGIN { - eval ' use IO::Uncompress::Adapter::Inflate 2.003 ;'; - eval ' use IO::Uncompress::Adapter::Bunzip2 2.003 ;'; - eval ' use IO::Uncompress::Adapter::LZO 2.003 ;'; - eval ' use IO::Uncompress::Adapter::Lzf 2.003 ;'; - - eval ' use IO::Uncompress::Bunzip2 2.003 ;'; - eval ' use IO::Uncompress::UnLzop 2.003 ;'; - eval ' use IO::Uncompress::Gunzip 2.003 ;'; - eval ' use IO::Uncompress::Inflate 2.003 ;'; - eval ' use IO::Uncompress::RawInflate 2.003 ;'; - eval ' use IO::Uncompress::Unzip 2.003 ;'; - eval ' use IO::Uncompress::UnLzf 2.003 ;'; + eval ' use IO::Uncompress::Adapter::Inflate 2.004 ;'; + eval ' use IO::Uncompress::Adapter::Bunzip2 2.004 ;'; + eval ' use IO::Uncompress::Adapter::LZO 2.004 ;'; + eval ' use IO::Uncompress::Adapter::Lzf 2.004 ;'; + + eval ' use IO::Uncompress::Bunzip2 2.004 ;'; + eval ' use IO::Uncompress::UnLzop 2.004 ;'; + eval ' use IO::Uncompress::Gunzip 2.004 ;'; + eval ' use IO::Uncompress::Inflate 2.004 ;'; + eval ' use IO::Uncompress::RawInflate 2.004 ;'; + eval ' use IO::Uncompress::Unzip 2.004 ;'; + eval ' use IO::Uncompress::UnLzf 2.004 ;'; } sub new @@ -56,7 +56,7 @@ sub anyuncompress sub getExtraParams { - use IO::Compress::Base::Common 2.003 qw(:Parse); + use IO::Compress::Base::Common 2.004 qw(:Parse); return ( 'RawInflate' => [1, 1, Parse_boolean, 0] ) ; } diff --git a/ext/IO/Compress/Base/lib/IO/Uncompress/Base.pm b/ext/IO/Compress/Base/lib/IO/Uncompress/Base.pm index 709d705499..1563dbab2c 100644 --- a/ext/IO/Compress/Base/lib/IO/Uncompress/Base.pm +++ b/ext/IO/Compress/Base/lib/IO/Uncompress/Base.pm @@ -10,12 +10,12 @@ our (@ISA, $VERSION, @EXPORT_OK, %EXPORT_TAGS); @ISA = qw(Exporter ); -$VERSION = '2.003'; +$VERSION = '2.004'; use constant G_EOF => 0 ; use constant G_ERR => -1 ; -use IO::Compress::Base::Common 2.003 ; +use IO::Compress::Base::Common 2.004 ; #use Parse::Parameters ; use IO::File ; @@ -301,6 +301,8 @@ sub checkParams 'Scan' => [1, 1, Parse_boolean, 0], 'InputLength' => [1, 1, Parse_unsigned, undef], 'BinModeOut' => [1, 1, Parse_boolean, 0], + #'Encode' => [1, 1, Parse_any, undef], + #'ConsumeInput' => [1, 1, Parse_boolean, 0], $self->getExtraParams(), @@ -380,6 +382,11 @@ sub _create *$obj->{Buffer} = \$buff ; } + if ($got->parsed('Encode')) { + my $want_encoding = $got->value('Encode'); + *$obj->{Encoding} = getEncoding($obj, $class, $want_encoding); + } + *$obj->{InputLength} = $got->parsed('InputLength') ? $got->value('InputLength') @@ -807,19 +814,19 @@ sub _raw_read $self->postBlockChk($buffer, $before_len) == STATUS_OK or return G_ERR; - $self->filterUncompressed($buffer); - - # TODO uncompress filter goes here - - $buf_len = length($$buffer) - $before_len; - *$self->{CompSize}->add($beforeC_len - length $temp_buf) ; *$self->{InflatedBytesRead} += $buf_len ; *$self->{TotalInflatedBytesRead} += $buf_len ; *$self->{UnCompSize}->add($buf_len) ; + + $self->filterUncompressed($buffer); + + if (*$self->{Encoding}) { + $$buffer = *$self->{Encoding}->decode($$buffer); + } } if ($status == STATUS_ENDSTREAM) { @@ -1271,11 +1278,14 @@ sub seek # Walk the file to the new offset my $offset = $target - $here ; - my $buffer ; - $self->read($buffer, $offset) == $offset - or return 0 ; + my $got; + while (($got = $self->read(my $buffer, min($offset, *$self->{BlockSize})) ) > 0) + { + $offset -= $got; + last if $offset == 0 ; + } - return 1 ; + return $offset == 0 ? 1 : 0 ; } sub fileno diff --git a/ext/IO/Compress/Zlib/Changes b/ext/IO/Compress/Zlib/Changes index 4e616b4a41..e5c95f87a3 100644 --- a/ext/IO/Compress/Zlib/Changes +++ b/ext/IO/Compress/Zlib/Changes @@ -1,6 +1,28 @@ CHANGES ------- + 2.004 3 March 2007 + + * IO::Compress::Zip + + - Added Zip64 documentation. + + - Fixed extended timestamp. + Creation time isn't available in Unix so only store the + modification time and the last access time in the extended field. + + - Fixed file mode. + + - Added ExtAttr option to control the value of the "external file + attributes" field in the central directory. + + - Added Unix2 extended attribute ("Ux"). + This stores the UID & GID. + + * IO::Compress::Gzip + + - Fixed 050interop-gzip.t for Windows + 2.003 2 January 2007 * Added explicit version checking diff --git a/ext/IO/Compress/Zlib/Makefile.PL b/ext/IO/Compress/Zlib/Makefile.PL index 0368115296..4d38fc7fa9 100644 --- a/ext/IO/Compress/Zlib/Makefile.PL +++ b/ext/IO/Compress/Zlib/Makefile.PL @@ -3,7 +3,7 @@ use strict ; require 5.004 ; -$::VERSION = '2.003' ; +$::VERSION = '2.004' ; use private::MakeUtil; use ExtUtils::MakeMaker 5.16 ; @@ -39,6 +39,9 @@ WriteMakefile( : () ), + ((ExtUtils::MakeMaker->VERSION() gt '6.30') ? + ('LICENSE' => 'perl') : ()), + ) ; # end of file Makefile.PL diff --git a/ext/IO/Compress/Zlib/README b/ext/IO/Compress/Zlib/README index 9bdda20a89..d0e48d4248 100644 --- a/ext/IO/Compress/Zlib/README +++ b/ext/IO/Compress/Zlib/README @@ -1,9 +1,9 @@ IO::Compress::Zlib - Version 2.003 + Version 2.004 - 2nd January 2007 + 3rd March 2007 Copyright (c) 2005-2007 Paul Marquess. All rights reserved. diff --git a/ext/IO/Compress/Zlib/lib/IO/Compress/Adapter/Deflate.pm b/ext/IO/Compress/Zlib/lib/IO/Compress/Adapter/Deflate.pm index c8b43bd2ef..1937c7ccbe 100644 --- a/ext/IO/Compress/Zlib/lib/IO/Compress/Adapter/Deflate.pm +++ b/ext/IO/Compress/Zlib/lib/IO/Compress/Adapter/Deflate.pm @@ -4,12 +4,12 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.003 qw(:Status); +use IO::Compress::Base::Common 2.004 qw(:Status); -use Compress::Raw::Zlib 2.003 qw(Z_OK Z_FINISH MAX_WBITS) ; +use Compress::Raw::Zlib 2.004 qw(Z_OK Z_FINISH MAX_WBITS) ; our ($VERSION); -$VERSION = '2.003'; +$VERSION = '2.004'; sub mkCompObject { diff --git a/ext/IO/Compress/Zlib/lib/IO/Compress/Adapter/Identity.pm b/ext/IO/Compress/Zlib/lib/IO/Compress/Adapter/Identity.pm index 15af46763c..596b670d4c 100644 --- a/ext/IO/Compress/Zlib/lib/IO/Compress/Adapter/Identity.pm +++ b/ext/IO/Compress/Zlib/lib/IO/Compress/Adapter/Identity.pm @@ -4,10 +4,10 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.003 qw(:Status); +use IO::Compress::Base::Common 2.004 qw(:Status); our ($VERSION); -$VERSION = '2.003'; +$VERSION = '2.004'; sub mkCompObject { diff --git a/ext/IO/Compress/Zlib/lib/IO/Compress/Deflate.pm b/ext/IO/Compress/Zlib/lib/IO/Compress/Deflate.pm index ff69332831..0015505a54 100644 --- a/ext/IO/Compress/Zlib/lib/IO/Compress/Deflate.pm +++ b/ext/IO/Compress/Zlib/lib/IO/Compress/Deflate.pm @@ -6,16 +6,16 @@ use bytes; require Exporter ; -use IO::Compress::RawDeflate 2.003 ; +use IO::Compress::RawDeflate 2.004 ; -use Compress::Raw::Zlib 2.003 ; -use IO::Compress::Zlib::Constants 2.003 ; -use IO::Compress::Base::Common 2.003 qw(createSelfTiedObject); +use Compress::Raw::Zlib 2.004 ; +use IO::Compress::Zlib::Constants 2.004 ; +use IO::Compress::Base::Common 2.004 qw(createSelfTiedObject); our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $DeflateError); -$VERSION = '2.003'; +$VERSION = '2.004'; $DeflateError = ''; @ISA = qw(Exporter IO::Compress::RawDeflate); diff --git a/ext/IO/Compress/Zlib/lib/IO/Compress/Gzip.pm b/ext/IO/Compress/Zlib/lib/IO/Compress/Gzip.pm index c4253b6e0a..5d1656447d 100644 --- a/ext/IO/Compress/Zlib/lib/IO/Compress/Gzip.pm +++ b/ext/IO/Compress/Zlib/lib/IO/Compress/Gzip.pm @@ -8,12 +8,12 @@ use warnings; use bytes; -use IO::Compress::RawDeflate 2.003 ; +use IO::Compress::RawDeflate 2.004 ; -use Compress::Raw::Zlib 2.003 ; -use IO::Compress::Base::Common 2.003 qw(:Status :Parse createSelfTiedObject); -use IO::Compress::Gzip::Constants 2.003 ; -use IO::Compress::Zlib::Extra 2.003 ; +use Compress::Raw::Zlib 2.004 ; +use IO::Compress::Base::Common 2.004 qw(:Status :Parse createSelfTiedObject); +use IO::Compress::Gzip::Constants 2.004 ; +use IO::Compress::Zlib::Extra 2.004 ; BEGIN { @@ -27,7 +27,7 @@ require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $GzipError); -$VERSION = '2.003'; +$VERSION = '2.004'; $GzipError = '' ; @ISA = qw(Exporter IO::Compress::RawDeflate); diff --git a/ext/IO/Compress/Zlib/lib/IO/Compress/Gzip/Constants.pm b/ext/IO/Compress/Zlib/lib/IO/Compress/Gzip/Constants.pm index 4e47f731ac..3ccb04210c 100644 --- a/ext/IO/Compress/Zlib/lib/IO/Compress/Gzip/Constants.pm +++ b/ext/IO/Compress/Zlib/lib/IO/Compress/Gzip/Constants.pm @@ -9,7 +9,7 @@ require Exporter; our ($VERSION, @ISA, @EXPORT, %GZIP_OS_Names); our ($GZIP_FNAME_INVALID_CHAR_RE, $GZIP_FCOMMENT_INVALID_CHAR_RE); -$VERSION = '2.003'; +$VERSION = '2.004'; @ISA = qw(Exporter); diff --git a/ext/IO/Compress/Zlib/lib/IO/Compress/RawDeflate.pm b/ext/IO/Compress/Zlib/lib/IO/Compress/RawDeflate.pm index 0cd340b703..11a2ae37df 100644 --- a/ext/IO/Compress/Zlib/lib/IO/Compress/RawDeflate.pm +++ b/ext/IO/Compress/Zlib/lib/IO/Compress/RawDeflate.pm @@ -7,16 +7,16 @@ use warnings; use bytes; -use IO::Compress::Base 2.003 ; -use IO::Compress::Base::Common 2.003 qw(:Status createSelfTiedObject); -use IO::Compress::Adapter::Deflate 2.003 ; +use IO::Compress::Base 2.004 ; +use IO::Compress::Base::Common 2.004 qw(:Status createSelfTiedObject); +use IO::Compress::Adapter::Deflate 2.004 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %DEFLATE_CONSTANTS, %EXPORT_TAGS, $RawDeflateError); -$VERSION = '2.003'; +$VERSION = '2.004'; $RawDeflateError = ''; @ISA = qw(Exporter IO::Compress::Base); @@ -141,8 +141,8 @@ sub getZlibParams { my $self = shift ; - use IO::Compress::Base::Common 2.003 qw(:Parse); - use Compress::Raw::Zlib 2.003 qw(Z_DEFLATED Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY); + use IO::Compress::Base::Common 2.004 qw(:Parse); + use Compress::Raw::Zlib 2.004 qw(Z_DEFLATED Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY); return ( diff --git a/ext/IO/Compress/Zlib/lib/IO/Compress/Zip.pm b/ext/IO/Compress/Zlib/lib/IO/Compress/Zip.pm index 899cbbe299..143760e3d5 100644 --- a/ext/IO/Compress/Zlib/lib/IO/Compress/Zip.pm +++ b/ext/IO/Compress/Zlib/lib/IO/Compress/Zip.pm @@ -4,21 +4,21 @@ use strict ; use warnings; use bytes; -use IO::Compress::Base::Common 2.003 qw(:Status createSelfTiedObject); -use IO::Compress::RawDeflate 2.003 ; -use IO::Compress::Adapter::Deflate 2.003 ; -use IO::Compress::Adapter::Identity 2.003 ; -use IO::Compress::Zlib::Extra 2.003 ; -use IO::Compress::Zip::Constants 2.003 ; +use IO::Compress::Base::Common 2.004 qw(:Status createSelfTiedObject); +use IO::Compress::RawDeflate 2.004 ; +use IO::Compress::Adapter::Deflate 2.004 ; +use IO::Compress::Adapter::Identity 2.004 ; +use IO::Compress::Zlib::Extra 2.004 ; +use IO::Compress::Zip::Constants 2.004 ; -use Compress::Raw::Zlib 2.003 qw(crc32) ; +use Compress::Raw::Zlib 2.004 qw(crc32) ; BEGIN { eval { require IO::Compress::Adapter::Bzip2 ; - import IO::Compress::Adapter::Bzip2 2.003 ; + import IO::Compress::Adapter::Bzip2 2.004 ; require IO::Compress::Bzip2 ; - import IO::Compress::Bzip2 2.003 ; + import IO::Compress::Bzip2 2.004 ; } ; } @@ -27,7 +27,7 @@ require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $ZipError); -$VERSION = '2.003'; +$VERSION = '2.004'; $ZipError = ''; @ISA = qw(Exporter IO::Compress::RawDeflate); @@ -139,6 +139,8 @@ sub mkHeader my $extra = ''; my $ctlExtra = ''; my $empty = 0; + my $osCode = $param->value('OS_Code') ; + my $extFileAttr = 0 ; if (*$self->{ZipData}{Zip64}) { $empty = 0xFFFF; @@ -164,11 +166,18 @@ sub mkHeader $ctlExtra .= mkExtendedTime($param->value('MTime')); } - # if ( $param->value('UID')) - # { - # $extra .= mkUnixExtra( $param->value('UID'), $param->value('GID')); - # $ctlExtra .= mkUnixExtra(); - # } + if ( $param->value('UID') && $osCode == ZIP_OS_CODE_UNIX) + { + $extra .= mkUnix2Extra( $param->value('UID'), $param->value('GID')); + $ctlExtra .= mkUnix2Extra(); + } + + # TODO - this code assumes Unix. + #$extFileAttr = 0666 << 16 + # if $osCode == ZIP_OS_CODE_UNIX ; + + $extFileAttr = $param->value('ExtAttr') + if defined $param->value('ExtAttr') ; $extra .= $param->value('ExtraFieldLocal') if defined $param->value('ExtraFieldLocal'); @@ -177,12 +186,6 @@ sub mkHeader if defined $param->value('ExtraFieldCentral'); } - - # TODO - this code assumes Unix. - my $extAttr = 0; - $extAttr = $param->value('Mode') << 16 - if defined $param->value('Mode') ; - my $gpFlag = 0 ; $gpFlag |= ZIP_GP_FLAG_STREAMING_MASK if *$self->{ZipData}{Stream} ; @@ -233,7 +236,7 @@ sub mkHeader $ctl .= pack 'v', length $comment ; # file comment length $ctl .= pack 'v', 0 ; # disk number start $ctl .= pack 'v', $ifa ; # internal file attributes - $ctl .= pack 'V', $extAttr ; # external file attributes + $ctl .= pack 'V', $extFileAttr ; # external file attributes if (! *$self->{ZipData}{Zip64}) { $ctl .= pack 'V', *$self->{ZipData}{Offset}->get32bit() ; # offset to local header } @@ -438,8 +441,8 @@ sub getExtraParams { my $self = shift ; - use IO::Compress::Base::Common 2.003 qw(:Parse); - use Compress::Raw::Zlib 2.003 qw(Z_DEFLATED Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY); + use IO::Compress::Base::Common 2.004 qw(:Parse); + use Compress::Raw::Zlib 2.004 qw(Z_DEFLATED Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY); my @Bzip2 = (); @@ -462,6 +465,7 @@ sub getExtraParams 'Name' => [0, 1, Parse_any, ''], 'Time' => [0, 1, Parse_any, undef], 'exTime' => [0, 1, Parse_any, undef], + 'ExtAttr' => [0, 1, Parse_any, 0], 'OS_Code' => [0, 1, Parse_unsigned, $Compress::Raw::Zlib::gzip_os_code], 'TextFlag' => [0, 1, Parse_boolean, 0], @@ -497,10 +501,11 @@ sub getFileInfo { $params->value('MTime' => $mtime) ; $params->value('ATime' => $atime) ; - $params->value('CTime' => $ctime) ; + $params->value('CTime' => undef) ; # No Creation time } - $params->value('Mode' => $mode) ; + $params->value('ExtAttr' => $mode << 16) + if ! $params->parsed('ExtAttr'); $params->value('UID' => $uid) ; $params->value('GID' => $gid) ; @@ -526,12 +531,11 @@ sub mkExtendedTime $bit <<= 1 ; } - #return "UT" . pack("v C", length($times) + 1, $flags) . $times; return IO::Compress::Zlib::Extra::mkSubField(ZIP_EXTRA_ID_EXT_TIMESTAMP, pack("C", $flags) . $times); } -sub mkUnixExtra +sub mkUnix2Extra { my $ids = ''; for my $id (@_) @@ -539,8 +543,8 @@ sub mkUnixExtra $ids .= pack("v", $id); } - #return "Ux" . pack("v", length $ids) . $ids; - return IO::Compress::Zlib::Extra::mkSubField(ZIP_EXTRA_ID_INFO_ZIP_UNIX, $ids); + return IO::Compress::Zlib::Extra::mkSubField(ZIP_EXTRA_ID_INFO_ZIP_UNIX2, + $ids); } @@ -630,11 +634,16 @@ compressed data to files or buffer. - The primary purpose of this module is to provide streaming write access to zip files and buffers. It is not a general-purpose file archiver. If that is what you want, check out C<Archive::Zip>. +At present three compression methods are supported by IO::Compress::Zip, +namely Store (no compression at all), Deflate and Bzip2. + +Note that to create Bzip2 content, the module C<IO::Compress::Bzip2> must +be installed. + @@ -719,10 +728,10 @@ If the C<$input> parameter is any other type, C<undef> will be returned. In addition, if C<$input> is a simple filename, the default values for -the C<Name>, C<Time> and C<exTime> options will be sourced from that file. +the C<Name>, C<Time>, C<ExtAttr> and C<exTime> options will be sourced from that file. If you do not want to use these defaults they can be overridden by -explicitly setting the C<Name>, C<Time> and C<exTime> options or by setting the +explicitly setting the C<Name>, C<Time>, C<ExtAttr> and C<exTime> options or by setting the C<Minimal> parameter. @@ -988,6 +997,13 @@ Sets the last modified time field in the zip header to $number. This field defaults to the time the C<IO::Compress::Zip> object was created if this option is not specified. +=item C<< ExtAttr => $attr >> + +This option controls the "external file attributes" field in the central +header of the zip file. This is a 4 byte field. + +This option defaults to 0. + =item C<< exTime => [$atime, $mtime, $ctime] >> This option expects an array reference with exactly three elements: @@ -998,6 +1014,11 @@ It uses these values to set the extended timestamp field in the local zip header to the three values, $atime, $mtime, $ctime and sets the extended timestamp field in the central zip header to C<$mtime>. +If any of the three values is C<undef> that time value will not be used. +So, for example, to set only the C<$mtime> you would use this + + exTime => [undef, $mtime, undef] + If the C<Minimal> option is set to true, this option will be ignored. By default no extended time field is created. @@ -1047,7 +1068,22 @@ is 0), the output file must be seekable. The default is 1. +=item C<< Zip64 => 0|1 >> + +Create a Zip64 zip file/buffer. This option should only be used if you want +to store files larger than 4 Gig. +If you intend to manipulate the Zip64 zip files created with this module +using an external zip/unzip make sure that it supports streaming Zip64. + +In particular, if you are using Info-Zip you need to have zip version 3.x +or better to update a Zip64 archive and unzip version 6.x to read a zip64 +archive. At the time of writing both are beta status. + +When the C<Zip64> option is enabled, the C<Stream> option I<must> be +enabled as well. + +The default is 0. =item C<< TextFlag => 0|1 >> @@ -1093,6 +1129,9 @@ Alternatively the list of subfields can by supplied as a scalar, thus ExtraField => $rawdata +The Extended Time field, set using the C<exTime> option, is an example of +an extended field. + If the C<Minimal> option is set to true, this option will be ignored. @@ -1102,7 +1141,8 @@ The maximum size of an extra field 65535 bytes. =item C<< Minimal => 1|0 >> If specified, this option will disable the creation of all extended fields -in the zip local and central headers. +in the zip local and central headers. So the C<exTime>, C<ExtraFieldLocal> +and C<ExtraFieldCentral> options will be ignored. This parameter defaults to 0. diff --git a/ext/IO/Compress/Zlib/lib/IO/Compress/Zip/Constants.pm b/ext/IO/Compress/Zlib/lib/IO/Compress/Zip/Constants.pm index dc8912d55e..b0505d6c40 100644 --- a/ext/IO/Compress/Zlib/lib/IO/Compress/Zip/Constants.pm +++ b/ext/IO/Compress/Zlib/lib/IO/Compress/Zip/Constants.pm @@ -7,7 +7,7 @@ require Exporter; our ($VERSION, @ISA, @EXPORT, %ZIP_CM_MIN_VERSIONS); -$VERSION = '2.003'; +$VERSION = '2.004'; @ISA = qw(Exporter); @@ -16,6 +16,7 @@ $VERSION = '2.003'; ZIP_CM_STORE ZIP_CM_DEFLATE ZIP_CM_BZIP2 + ZIP_CM_LZMA ZIP_LOCAL_HDR_SIG ZIP_DATA_HDR_SIG @@ -33,7 +34,10 @@ $VERSION = '2.003'; ZIP_EXTRA_ID_ZIP64 ZIP_EXTRA_ID_EXT_TIMESTAMP - ZIP_EXTRA_ID_INFO_ZIP_UNIX + ZIP_EXTRA_ID_INFO_ZIP_UNIX2 + + ZIP_OS_CODE_UNIX + ZIP_OS_CODE_DEFAULT ZIP_IFA_TEXT_MASK @@ -46,6 +50,7 @@ $VERSION = '2.003'; use constant ZIP_CM_STORE => 0 ; use constant ZIP_CM_DEFLATE => 8 ; use constant ZIP_CM_BZIP2 => 12 ; +use constant ZIP_CM_LZMA => 14 ; # Not Supported yet # General Purpose Flag use constant ZIP_GP_FLAG_ENCRYPTED_MASK => 1 ; @@ -66,10 +71,13 @@ use constant ZIP64_END_CENTRAL_LOC_HDR_SIG => 0x07064b50; use constant ZIP64_ARCHIVE_EXTRA_SIG => 0x08064b50; use constant ZIP64_DIGITAL_SIGNATURE_SIG => 0x05054b50; +use constant ZIP_OS_CODE_UNIX => 3; +use constant ZIP_OS_CODE_DEFAULT => 3; + # Extra Field ID's use constant ZIP_EXTRA_ID_ZIP64 => pack "v", 1; use constant ZIP_EXTRA_ID_EXT_TIMESTAMP => "UT"; -use constant ZIP_EXTRA_ID_INFO_ZIP_UNIX => "Ux"; +use constant ZIP_EXTRA_ID_INFO_ZIP_UNIX2 => "Ux"; use constant ZIP64_MIN_VERSION => 45; @@ -77,6 +85,7 @@ use constant ZIP64_MIN_VERSION => 45; ZIP_CM_STORE() => 20, ZIP_CM_DEFLATE() => 20, ZIP_CM_BZIP2() => 46, + ZIP_CM_LZMA() => 63, ); diff --git a/ext/IO/Compress/Zlib/lib/IO/Compress/Zlib/Constants.pm b/ext/IO/Compress/Zlib/lib/IO/Compress/Zlib/Constants.pm index 694f9ec6c8..492b2e3ddd 100644 --- a/ext/IO/Compress/Zlib/lib/IO/Compress/Zlib/Constants.pm +++ b/ext/IO/Compress/Zlib/lib/IO/Compress/Zlib/Constants.pm @@ -9,7 +9,7 @@ require Exporter; our ($VERSION, @ISA, @EXPORT); -$VERSION = '2.003'; +$VERSION = '2.004'; @ISA = qw(Exporter); diff --git a/ext/IO/Compress/Zlib/lib/IO/Compress/Zlib/Extra.pm b/ext/IO/Compress/Zlib/lib/IO/Compress/Zlib/Extra.pm index 7f9f7b0511..4034e3a481 100644 --- a/ext/IO/Compress/Zlib/lib/IO/Compress/Zlib/Extra.pm +++ b/ext/IO/Compress/Zlib/lib/IO/Compress/Zlib/Extra.pm @@ -8,9 +8,9 @@ use bytes; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS); -$VERSION = '2.003'; +$VERSION = '2.004'; -use IO::Compress::Gzip::Constants 2.003 ; +use IO::Compress::Gzip::Constants 2.004 ; sub ExtraFieldError { diff --git a/ext/IO/Compress/Zlib/lib/IO/Uncompress/Adapter/Identity.pm b/ext/IO/Compress/Zlib/lib/IO/Uncompress/Adapter/Identity.pm index 4a3b316524..36b9fbbce3 100644 --- a/ext/IO/Compress/Zlib/lib/IO/Uncompress/Adapter/Identity.pm +++ b/ext/IO/Compress/Zlib/lib/IO/Uncompress/Adapter/Identity.pm @@ -4,13 +4,13 @@ use warnings; use strict; use bytes; -use IO::Compress::Base::Common 2.003 qw(:Status); +use IO::Compress::Base::Common 2.004 qw(:Status); our ($VERSION); -$VERSION = '2.003'; +$VERSION = '2.004'; -use Compress::Raw::Zlib 2.003 (); +use Compress::Raw::Zlib 2.004 (); sub mkUncompObject { diff --git a/ext/IO/Compress/Zlib/lib/IO/Uncompress/Adapter/Inflate.pm b/ext/IO/Compress/Zlib/lib/IO/Uncompress/Adapter/Inflate.pm index 96e42cc869..6131c14140 100644 --- a/ext/IO/Compress/Zlib/lib/IO/Uncompress/Adapter/Inflate.pm +++ b/ext/IO/Compress/Zlib/lib/IO/Uncompress/Adapter/Inflate.pm @@ -4,11 +4,11 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.003 qw(:Status); -use Compress::Raw::Zlib 2.003 qw(Z_OK Z_DATA_ERROR Z_STREAM_END Z_FINISH MAX_WBITS); +use IO::Compress::Base::Common 2.004 qw(:Status); +use Compress::Raw::Zlib 2.004 qw(Z_OK Z_DATA_ERROR Z_STREAM_END Z_FINISH MAX_WBITS); our ($VERSION); -$VERSION = '2.003'; +$VERSION = '2.004'; diff --git a/ext/IO/Compress/Zlib/lib/IO/Uncompress/AnyInflate.pm b/ext/IO/Compress/Zlib/lib/IO/Uncompress/AnyInflate.pm index 938013fc04..04c53ba7e6 100644 --- a/ext/IO/Compress/Zlib/lib/IO/Uncompress/AnyInflate.pm +++ b/ext/IO/Compress/Zlib/lib/IO/Uncompress/AnyInflate.pm @@ -6,22 +6,22 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.003 qw(createSelfTiedObject); +use IO::Compress::Base::Common 2.004 qw(createSelfTiedObject); -use IO::Uncompress::Adapter::Inflate 2.003 (); +use IO::Uncompress::Adapter::Inflate 2.004 (); -use IO::Uncompress::Base 2.003 ; -use IO::Uncompress::Gunzip 2.003 ; -use IO::Uncompress::Inflate 2.003 ; -use IO::Uncompress::RawInflate 2.003 ; -use IO::Uncompress::Unzip 2.003 ; +use IO::Uncompress::Base 2.004 ; +use IO::Uncompress::Gunzip 2.004 ; +use IO::Uncompress::Inflate 2.004 ; +use IO::Uncompress::RawInflate 2.004 ; +use IO::Uncompress::Unzip 2.004 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $AnyInflateError); -$VERSION = '2.003'; +$VERSION = '2.004'; $AnyInflateError = ''; @ISA = qw( Exporter IO::Uncompress::Base ); @@ -48,7 +48,7 @@ sub anyinflate sub getExtraParams { - use IO::Compress::Base::Common 2.003 qw(:Parse); + use IO::Compress::Base::Common 2.004 qw(:Parse); return ( 'RawInflate' => [1, 1, Parse_boolean, 0] ) ; } diff --git a/ext/IO/Compress/Zlib/lib/IO/Uncompress/Gunzip.pm b/ext/IO/Compress/Zlib/lib/IO/Uncompress/Gunzip.pm index d350bec131..75dcf4ba42 100644 --- a/ext/IO/Compress/Zlib/lib/IO/Uncompress/Gunzip.pm +++ b/ext/IO/Compress/Zlib/lib/IO/Uncompress/Gunzip.pm @@ -9,12 +9,12 @@ use strict ; use warnings; use bytes; -use IO::Uncompress::RawInflate 2.003 ; +use IO::Uncompress::RawInflate 2.004 ; -use Compress::Raw::Zlib 2.003 qw( crc32 ) ; -use IO::Compress::Base::Common 2.003 qw(:Status createSelfTiedObject); -use IO::Compress::Gzip::Constants 2.003 ; -use IO::Compress::Zlib::Extra 2.003 ; +use Compress::Raw::Zlib 2.004 qw( crc32 ) ; +use IO::Compress::Base::Common 2.004 qw(:Status createSelfTiedObject); +use IO::Compress::Gzip::Constants 2.004 ; +use IO::Compress::Zlib::Extra 2.004 ; require Exporter ; @@ -28,7 +28,7 @@ Exporter::export_ok_tags('all'); $GunzipError = ''; -$VERSION = '2.003'; +$VERSION = '2.004'; sub new { @@ -47,7 +47,7 @@ sub gunzip sub getExtraParams { - use IO::Compress::Base::Common 2.003 qw(:Parse); + use IO::Compress::Base::Common 2.004 qw(:Parse); return ( 'ParseExtra' => [1, 1, Parse_boolean, 0] ) ; } diff --git a/ext/IO/Compress/Zlib/lib/IO/Uncompress/Inflate.pm b/ext/IO/Compress/Zlib/lib/IO/Uncompress/Inflate.pm index d2dc05dc46..c39170d44b 100644 --- a/ext/IO/Compress/Zlib/lib/IO/Uncompress/Inflate.pm +++ b/ext/IO/Compress/Zlib/lib/IO/Uncompress/Inflate.pm @@ -5,15 +5,15 @@ use strict ; use warnings; use bytes; -use IO::Compress::Base::Common 2.003 qw(:Status createSelfTiedObject); -use IO::Compress::Zlib::Constants 2.003 ; +use IO::Compress::Base::Common 2.004 qw(:Status createSelfTiedObject); +use IO::Compress::Zlib::Constants 2.004 ; -use IO::Uncompress::RawInflate 2.003 ; +use IO::Uncompress::RawInflate 2.004 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $InflateError); -$VERSION = '2.003'; +$VERSION = '2.004'; $InflateError = ''; @ISA = qw( Exporter IO::Uncompress::RawInflate ); diff --git a/ext/IO/Compress/Zlib/lib/IO/Uncompress/RawInflate.pm b/ext/IO/Compress/Zlib/lib/IO/Uncompress/RawInflate.pm index f7a3b1ee2c..a811e656de 100644 --- a/ext/IO/Compress/Zlib/lib/IO/Uncompress/RawInflate.pm +++ b/ext/IO/Compress/Zlib/lib/IO/Uncompress/RawInflate.pm @@ -5,11 +5,11 @@ use strict ; use warnings; use bytes; -use Compress::Raw::Zlib 2.003 ; -use IO::Compress::Base::Common 2.003 qw(:Status createSelfTiedObject); +use Compress::Raw::Zlib 2.004 ; +use IO::Compress::Base::Common 2.004 qw(:Status createSelfTiedObject); -use IO::Uncompress::Base 2.003 ; -use IO::Uncompress::Adapter::Inflate 2.003 ; +use IO::Uncompress::Base 2.004 ; +use IO::Uncompress::Adapter::Inflate 2.004 ; @@ -17,7 +17,7 @@ use IO::Uncompress::Adapter::Inflate 2.003 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, %DEFLATE_CONSTANTS, $RawInflateError); -$VERSION = '2.003'; +$VERSION = '2.004'; $RawInflateError = ''; @ISA = qw( Exporter IO::Uncompress::Base ); diff --git a/ext/IO/Compress/Zlib/lib/IO/Uncompress/Unzip.pm b/ext/IO/Compress/Zlib/lib/IO/Uncompress/Unzip.pm index 63550e97c6..cab4d07538 100644 --- a/ext/IO/Compress/Zlib/lib/IO/Uncompress/Unzip.pm +++ b/ext/IO/Compress/Zlib/lib/IO/Uncompress/Unzip.pm @@ -8,13 +8,13 @@ use strict ; use warnings; use bytes; -use IO::Uncompress::RawInflate 2.003 ; -use IO::Compress::Base::Common 2.003 qw(:Status createSelfTiedObject); -use IO::Uncompress::Adapter::Identity 2.003 ; -use IO::Compress::Zlib::Extra 2.003 ; -use IO::Compress::Zip::Constants 2.003 ; +use IO::Uncompress::RawInflate 2.004 ; +use IO::Compress::Base::Common 2.004 qw(:Status createSelfTiedObject); +use IO::Uncompress::Adapter::Identity 2.004 ; +use IO::Compress::Zlib::Extra 2.004 ; +use IO::Compress::Zip::Constants 2.004 ; -use Compress::Raw::Zlib 2.003 qw(crc32) ; +use Compress::Raw::Zlib 2.004 qw(crc32) ; BEGIN { @@ -27,7 +27,7 @@ require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $UnzipError, %headerLookup); -$VERSION = '2.003'; +$VERSION = '2.004'; $UnzipError = ''; @ISA = qw(Exporter IO::Uncompress::RawInflate); @@ -60,7 +60,7 @@ sub unzip sub getExtraParams { - use IO::Compress::Base::Common 2.003 qw(:Parse); + use IO::Compress::Base::Common 2.004 qw(:Parse); return ( diff --git a/ext/IO/Compress/Zlib/t/050interop-gzip.t b/ext/IO/Compress/Zlib/t/050interop-gzip.t index 8c5788ddf8..22be0646c8 100644 --- a/ext/IO/Compress/Zlib/t/050interop-gzip.t +++ b/ext/IO/Compress/Zlib/t/050interop-gzip.t @@ -86,8 +86,10 @@ sub writeWithGzip BEGIN { # Check external gzip is available - my $name = 'gzip'; - for my $dir (reverse split ":", $ENV{PATH}) + my $name = $^O =~ /mswin/i ? 'gzip.exe' : 'gzip'; + my $split = $^O =~ /mswin/i ? ";" : ":"; + + for my $dir (reverse split $split, $ENV{PATH}) { $GZIP = "$dir/$name" if -x "$dir/$name" ; |