summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/IO/Compress/Zip.pm
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-04-23 21:46:20 +0000
committerKarl Berry <karl@freefriends.org>2014-04-23 21:46:20 +0000
commit300c1eb6d37d46078d448d6d58938d5a80cd68ff (patch)
tree23a0a8b9f8f5460b405119c4d3c163d2d488ca5e /Master/tlpkg/tlperl/lib/IO/Compress/Zip.pm
parented55d86b7c5e18f6eccce80a1fb1423ca40a23b5 (diff)
(tl)perl 5.18.2 for windows from siep
git-svn-id: svn://tug.org/texlive/trunk@33648 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/lib/IO/Compress/Zip.pm')
-rw-r--r--Master/tlpkg/tlperl/lib/IO/Compress/Zip.pm391
1 files changed, 200 insertions, 191 deletions
diff --git a/Master/tlpkg/tlperl/lib/IO/Compress/Zip.pm b/Master/tlpkg/tlperl/lib/IO/Compress/Zip.pm
index 9c2780a5e06..a5bf89ecc40 100644
--- a/Master/tlpkg/tlperl/lib/IO/Compress/Zip.pm
+++ b/Master/tlpkg/tlperl/lib/IO/Compress/Zip.pm
@@ -4,30 +4,30 @@ use strict ;
use warnings;
use bytes;
-use IO::Compress::Base::Common 2.048 qw(:Status MAX32 isGeMax32 isaScalar createSelfTiedObject);
-use IO::Compress::RawDeflate 2.048 ();
-use IO::Compress::Adapter::Deflate 2.048 ;
-use IO::Compress::Adapter::Identity 2.048 ;
-use IO::Compress::Zlib::Extra 2.048 ;
-use IO::Compress::Zip::Constants 2.048 ;
+use IO::Compress::Base::Common 2.060 qw(:Status );
+use IO::Compress::RawDeflate 2.060 ();
+use IO::Compress::Adapter::Deflate 2.060 ;
+use IO::Compress::Adapter::Identity 2.060 ;
+use IO::Compress::Zlib::Extra 2.060 ;
+use IO::Compress::Zip::Constants 2.060 ;
use File::Spec();
use Config;
-use Compress::Raw::Zlib 2.048 ();
+use Compress::Raw::Zlib 2.060 ();
BEGIN
{
eval { require IO::Compress::Adapter::Bzip2 ;
- import IO::Compress::Adapter::Bzip2 2.048 ;
+ import IO::Compress::Adapter::Bzip2 2.060 ;
require IO::Compress::Bzip2 ;
- import IO::Compress::Bzip2 2.048 ;
+ import IO::Compress::Bzip2 2.060 ;
} ;
eval { require IO::Compress::Adapter::Lzma ;
- import IO::Compress::Adapter::Lzma 2.048 ;
+ import IO::Compress::Adapter::Lzma 2.060 ;
require IO::Compress::Lzma ;
- import IO::Compress::Lzma 2.048 ;
+ import IO::Compress::Lzma 2.060 ;
} ;
}
@@ -36,7 +36,7 @@ require Exporter ;
our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, %DEFLATE_CONSTANTS, $ZipError);
-$VERSION = '2.048';
+$VERSION = '2.060';
$ZipError = '';
@ISA = qw(Exporter IO::Compress::RawDeflate);
@@ -54,14 +54,14 @@ sub new
{
my $class = shift ;
- my $obj = createSelfTiedObject($class, \$ZipError);
+ my $obj = IO::Compress::Base::Common::createSelfTiedObject($class, \$ZipError);
$obj->_create(undef, @_);
}
sub zip
{
- my $obj = createSelfTiedObject(undef, \$ZipError);
+ my $obj = IO::Compress::Base::Common::createSelfTiedObject(undef, \$ZipError);
return $obj->_def(@_);
}
@@ -114,30 +114,30 @@ sub mkComp
if (*$self->{ZipData}{Method} == ZIP_CM_STORE) {
($obj, $errstr, $errno) = IO::Compress::Adapter::Identity::mkCompObject(
- $got->value('Level'),
- $got->value('Strategy')
+ $got->getValue('level'),
+ $got->getValue('strategy')
);
*$self->{ZipData}{CRC32} = Compress::Raw::Zlib::crc32(undef);
}
elsif (*$self->{ZipData}{Method} == ZIP_CM_DEFLATE) {
($obj, $errstr, $errno) = IO::Compress::Adapter::Deflate::mkCompObject(
- $got->value('CRC32'),
- $got->value('Adler32'),
- $got->value('Level'),
- $got->value('Strategy')
+ $got->getValue('crc32'),
+ $got->getValue('adler32'),
+ $got->getValue('level'),
+ $got->getValue('strategy')
);
}
elsif (*$self->{ZipData}{Method} == ZIP_CM_BZIP2) {
($obj, $errstr, $errno) = IO::Compress::Adapter::Bzip2::mkCompObject(
- $got->value('BlockSize100K'),
- $got->value('WorkFactor'),
- $got->value('Verbosity')
+ $got->getValue('blocksize100k'),
+ $got->getValue('workfactor'),
+ $got->getValue('verbosity')
);
*$self->{ZipData}{CRC32} = Compress::Raw::Zlib::crc32(undef);
}
elsif (*$self->{ZipData}{Method} == ZIP_CM_LZMA) {
- ($obj, $errstr, $errno) = IO::Compress::Adapter::Lzma::mkRawZipCompObject($got->value('Preset'),
- $got->value('Extreme'),
+ ($obj, $errstr, $errno) = IO::Compress::Adapter::Lzma::mkRawZipCompObject($got->getValue('preset'),
+ $got->getValue('extreme'),
);
*$self->{ZipData}{CRC32} = Compress::Raw::Zlib::crc32(undef);
}
@@ -230,39 +230,38 @@ sub mkHeader
my $self = shift;
my $param = shift ;
-
*$self->{ZipData}{LocalHdrOffset} = U64::clone(*$self->{ZipData}{Offset});
-
+
my $comment = '';
- $comment = $param->value('Comment') || '';
+ $comment = $param->valueOrDefault('comment') ;
my $filename = '';
- $filename = $param->value('Name') || '';
+ $filename = $param->valueOrDefault('name') ;
$filename = canonicalName($filename)
- if length $filename && $param->value('CanonicalName') ;
+ if length $filename && $param->getValue('canonicalname') ;
if (defined *$self->{ZipData}{FilterName} ) {
local *_ = \$filename ;
&{ *$self->{ZipData}{FilterName} }() ;
}
-# if ( $param->value('UTF8') ) {
+# if ( $param->getValue('utf8') ) {
# require Encode ;
# $filename = Encode::encode_utf8($filename)
# if length $filename ;
-# $comment = Encode::encode_utf8($filename)
+# $comment = Encode::encode_utf8($comment)
# if length $comment ;
# }
my $hdr = '';
- my $time = _unixToDosTime($param->value('Time'));
+ my $time = _unixToDosTime($param->getValue('time'));
my $extra = '';
my $ctlExtra = '';
my $empty = 0;
- my $osCode = $param->value('OS_Code') ;
+ my $osCode = $param->getValue('os_code') ;
my $extFileAttr = 0 ;
# This code assumes Unix.
@@ -271,7 +270,7 @@ sub mkHeader
if $osCode == ZIP_OS_CODE_UNIX ;
if (*$self->{ZipData}{Zip64}) {
- $empty = MAX32;
+ $empty = IO::Compress::Base::Common::MAX32;
my $x = '';
$x .= pack "V V", 0, 0 ; # uncompressedLength
@@ -279,40 +278,40 @@ sub mkHeader
$extra .= IO::Compress::Zlib::Extra::mkSubField(ZIP_EXTRA_ID_ZIP64, $x);
}
- if (! $param->value('Minimal')) {
- if ($param->parsed('MTime'))
+ if (! $param->getValue('minimal')) {
+ if ($param->parsed('mtime'))
{
- $extra .= mkExtendedTime($param->value('MTime'),
- $param->value('ATime'),
- $param->value('CTime'));
+ $extra .= mkExtendedTime($param->getValue('mtime'),
+ $param->getValue('atime'),
+ $param->getValue('ctime'));
- $ctlExtra .= mkExtendedTime($param->value('MTime'));
+ $ctlExtra .= mkExtendedTime($param->getValue('mtime'));
}
if ( $osCode == ZIP_OS_CODE_UNIX )
{
- if ( $param->value('want_exUnixN') )
+ if ( $param->getValue('want_exunixn') )
{
- my $ux3 = mkUnixNExtra( @{ $param->value('want_exUnixN') });
+ my $ux3 = mkUnixNExtra( @{ $param->getValue('want_exunixn') });
$extra .= $ux3;
$ctlExtra .= $ux3;
}
- if ( $param->value('exUnix2') )
+ if ( $param->getValue('exunix2') )
{
- $extra .= mkUnix2Extra( @{ $param->value('exUnix2') });
+ $extra .= mkUnix2Extra( @{ $param->getValue('exunix2') });
$ctlExtra .= mkUnix2Extra();
}
}
- $extFileAttr = $param->value('ExtAttr')
- if defined $param->value('ExtAttr') ;
+ $extFileAttr = $param->getValue('extattr')
+ if defined $param->getValue('extattr') ;
- $extra .= $param->value('ExtraFieldLocal')
- if defined $param->value('ExtraFieldLocal');
+ $extra .= $param->getValue('extrafieldlocal')
+ if defined $param->getValue('extrafieldlocal');
- $ctlExtra .= $param->value('ExtraFieldCentral')
- if defined $param->value('ExtraFieldCentral');
+ $ctlExtra .= $param->getValue('extrafieldcentral')
+ if defined $param->getValue('extrafieldcentral');
}
my $method = *$self->{ZipData}{Method} ;
@@ -323,14 +322,14 @@ sub mkHeader
$gpFlag |= ZIP_GP_FLAG_LZMA_EOS_PRESENT
if $method == ZIP_CM_LZMA ;
- #$gpFlag |= ZIP_GP_FLAG_LANGUAGE_ENCODING
- #if $param->value('UTF8') && length($filename) + length($comment);
+# $gpFlag |= ZIP_GP_FLAG_LANGUAGE_ENCODING
+# if $param->getValue('utf8') && (length($filename) || length($comment));
my $version = $ZIP_CM_MIN_VERSIONS{$method};
$version = ZIP64_MIN_VERSION
if ZIP64_MIN_VERSION > $version && *$self->{ZipData}{Zip64};
- my $madeBy = ($param->value('OS_Code') << 8) + $version;
+ my $madeBy = ($param->getValue('os_code') << 8) + $version;
my $extract = $version;
*$self->{ZipData}{Version} = $version;
@@ -338,7 +337,7 @@ sub mkHeader
my $ifa = 0;
$ifa |= ZIP_IFA_TEXT_MASK
- if $param->value('TextFlag');
+ if $param->getValue('textflag');
$hdr .= pack "V", ZIP_LOCAL_HDR_SIG ; # signature
$hdr .= pack 'v', $extract ; # extract Version & OS
@@ -391,7 +390,7 @@ sub mkHeader
# offset to local hdr
if (*$self->{ZipData}{LocalHdrOffset}->is64bit() ) {
- $ctl .= pack 'V', MAX32 ;
+ $ctl .= pack 'V', IO::Compress::Base::Common::MAX32 ;
}
else {
$ctl .= *$self->{ZipData}{LocalHdrOffset}->getPacked_V32() ;
@@ -401,7 +400,7 @@ sub mkHeader
$ctl .= $ctlExtra ;
$ctl .= $comment ;
- *$self->{ZipData}{Offset}->add(length $hdr) ;
+ *$self->{ZipData}{Offset}->add32(length $hdr) ;
*$self->{ZipData}{CentralHeader} = $ctl;
@@ -489,7 +488,7 @@ sub mkTrailer
*$self->{ZipData}{AnyZip64} = 1;
}
- *$self->{ZipData}{Offset}->add(length($hdr));
+ *$self->{ZipData}{Offset}->add32(length($hdr));
*$self->{ZipData}{Offset}->add( *$self->{CompSize} );
push @{ *$self->{ZipData}{CentralDir} }, $ctl ;
@@ -499,13 +498,17 @@ sub mkTrailer
sub mkFinalTrailer
{
my $self = shift ;
-
+
my $comment = '';
$comment = *$self->{ZipData}{ZipComment} ;
my $cd_offset = *$self->{ZipData}{Offset}->get32bit() ; # offset to start central dir
my $entries = @{ *$self->{ZipData}{CentralDir} };
+
+ *$self->{ZipData}{AnyZip64} = 1
+ if *$self->{ZipData}{Offset}->is64bit || $entries >= 0xFFFF ;
+
my $cd = join '', @{ *$self->{ZipData}{CentralDir} };
my $cd_len = length $cd ;
@@ -528,15 +531,15 @@ sub mkFinalTrailer
. U64::pack_V64(length $z64e)
. $z64e ;
- *$self->{ZipData}{Offset}->add(length $cd) ;
+ *$self->{ZipData}{Offset}->add32(length $cd) ;
$z64e .= pack "V", ZIP64_END_CENTRAL_LOC_HDR_SIG; # signature
$z64e .= pack 'V', 0 ; # number of disk with central dir
$z64e .= *$self->{ZipData}{Offset}->getPacked_V64() ; # offset to end zip64 central dir
$z64e .= pack 'V', 1 ; # Total number of disks
- $cd_offset = MAX32 ;
- $cd_len = MAX32 if isGeMax32 $cd_len ;
+ $cd_offset = IO::Compress::Base::Common::MAX32 ;
+ $cd_len = IO::Compress::Base::Common::MAX32 if IO::Compress::Base::Common::isGeMax32 $cd_len ;
$entries = 0xFFFF if $entries >= 0xFFFF ;
}
@@ -559,47 +562,47 @@ sub ckParams
my $self = shift ;
my $got = shift;
- $got->value('CRC32' => 1);
+ $got->setValue('crc32' => 1);
- if (! $got->parsed('Time') ) {
+ if (! $got->parsed('time') ) {
# Modification time defaults to now.
- $got->value('Time' => time) ;
+ $got->setValue('time' => time) ;
}
- if ($got->parsed('exTime') ) {
- my $timeRef = $got->value('exTime');
+ if ($got->parsed('extime') ) {
+ my $timeRef = $got->getValue('extime');
if ( defined $timeRef) {
return $self->saveErrorString(undef, "exTime not a 3-element array ref")
if ref $timeRef ne 'ARRAY' || @$timeRef != 3;
}
- $got->value("MTime", $timeRef->[1]);
- $got->value("ATime", $timeRef->[0]);
- $got->value("CTime", $timeRef->[2]);
+ $got->setValue("mtime", $timeRef->[1]);
+ $got->setValue("atime", $timeRef->[0]);
+ $got->setValue("ctime", $timeRef->[2]);
}
# Unix2/3 Extended Attribute
- for my $name (qw(exUnix2 exUnixN))
+ for my $name (qw(exunix2 exunixn))
{
if ($got->parsed($name) ) {
- my $idRef = $got->value($name);
+ my $idRef = $got->getValue($name);
if ( defined $idRef) {
return $self->saveErrorString(undef, "$name not a 2-element array ref")
if ref $idRef ne 'ARRAY' || @$idRef != 2;
}
- $got->value("UID", $idRef->[0]);
- $got->value("GID", $idRef->[1]);
- $got->value("want_$name", $idRef);
+ $got->setValue("uid", $idRef->[0]);
+ $got->setValue("gid", $idRef->[1]);
+ $got->setValue("want_$name", $idRef);
}
}
*$self->{ZipData}{AnyZip64} = 1
- if $got->value('Zip64');
- *$self->{ZipData}{Zip64} = $got->value('Zip64');
- *$self->{ZipData}{Stream} = $got->value('Stream');
+ if $got->getValue('zip64');
+ *$self->{ZipData}{Zip64} = $got->getValue('zip64');
+ *$self->{ZipData}{Stream} = $got->getValue('stream');
- my $method = $got->value('Method');
+ my $method = $got->getValue('method');
return $self->saveErrorString(undef, "Unknown Method '$method'")
if ! defined $ZIP_CM_MIN_VERSIONS{$method};
@@ -613,17 +616,17 @@ sub ckParams
*$self->{ZipData}{Method} = $method;
- *$self->{ZipData}{ZipComment} = $got->value('ZipComment') ;
+ *$self->{ZipData}{ZipComment} = $got->getValue('zipcomment') ;
- for my $name (qw( ExtraFieldLocal ExtraFieldCentral ))
+ for my $name (qw( extrafieldlocal extrafieldcentral ))
{
- my $data = $got->value($name) ;
+ my $data = $got->getValue($name) ;
if (defined $data) {
my $bad = IO::Compress::Zlib::Extra::parseExtraField($data, 1, 0) ;
return $self->saveErrorString(undef, "Error with $name Parameter: $bad")
if $bad ;
- $got->value($name, $data) ;
+ $got->setValue($name, $data) ;
}
}
@@ -631,13 +634,13 @@ sub ckParams
if defined $IO::Compress::Bzip2::VERSION
and ! IO::Compress::Bzip2::ckParams($self, $got);
- if ($got->parsed('Sparse') ) {
- *$self->{ZipData}{Sparse} = $got->value('Sparse') ;
+ if ($got->parsed('sparse') ) {
+ *$self->{ZipData}{Sparse} = $got->getValue('sparse') ;
*$self->{ZipData}{Method} = ZIP_CM_STORE;
}
- if ($got->parsed('FilterName')) {
- my $v = $got->value('FilterName') ;
+ if ($got->parsed('filtername')) {
+ my $v = $got->getValue('filtername') ;
*$self->{ZipData}{FilterName} = $v
if ref $v eq 'CODE' ;
}
@@ -660,58 +663,53 @@ sub outputPayload
# return $self->mkHeader(*$self->{Got});
#}
-sub getExtraParams
-{
- my $self = shift ;
-
- use IO::Compress::Base::Common 2.048 qw(:Parse);
- use Compress::Raw::Zlib 2.048 qw(Z_DEFLATED Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY);
- my @Bzip2 = ();
-
- @Bzip2 = IO::Compress::Bzip2::getExtraParams($self)
- if defined $IO::Compress::Bzip2::VERSION;
-
- return (
- # zlib behaviour
- $self->getZlibParams(),
-
- 'Stream' => [1, 1, Parse_boolean, 1],
- #'Store' => [0, 1, Parse_boolean, 0],
- 'Method' => [0, 1, Parse_unsigned, ZIP_CM_DEFLATE],
+our %PARAMS = (
+ 'stream' => [IO::Compress::Base::Common::Parse_boolean, 1],
+ #'store' => [IO::Compress::Base::Common::Parse_boolean, 0],
+ 'method' => [IO::Compress::Base::Common::Parse_unsigned, ZIP_CM_DEFLATE],
# # Zip header fields
- 'Minimal' => [0, 1, Parse_boolean, 0],
- 'Zip64' => [0, 1, Parse_boolean, 0],
- 'Comment' => [0, 1, Parse_any, ''],
- 'ZipComment'=> [0, 1, Parse_any, ''],
- 'Name' => [0, 1, Parse_any, ''],
- 'FilterName'=> [0, 1, Parse_code, undef],
- 'CanonicalName'=> [0, 1, Parse_boolean, 0],
- #'UTF8' => [0, 1, Parse_boolean, 0],
- 'Time' => [0, 1, Parse_any, undef],
- 'exTime' => [0, 1, Parse_any, undef],
- 'exUnix2' => [0, 1, Parse_any, undef],
- 'exUnixN' => [0, 1, Parse_any, undef],
- 'ExtAttr' => [0, 1, Parse_any,
+ 'minimal' => [IO::Compress::Base::Common::Parse_boolean, 0],
+ 'zip64' => [IO::Compress::Base::Common::Parse_boolean, 0],
+ 'comment' => [IO::Compress::Base::Common::Parse_any, ''],
+ 'zipcomment'=> [IO::Compress::Base::Common::Parse_any, ''],
+ 'name' => [IO::Compress::Base::Common::Parse_any, ''],
+ 'filtername'=> [IO::Compress::Base::Common::Parse_code, undef],
+ 'canonicalname'=> [IO::Compress::Base::Common::Parse_boolean, 0],
+# 'utf8' => [IO::Compress::Base::Common::Parse_boolean, 0],
+ 'time' => [IO::Compress::Base::Common::Parse_any, undef],
+ 'extime' => [IO::Compress::Base::Common::Parse_any, undef],
+ 'exunix2' => [IO::Compress::Base::Common::Parse_any, undef],
+ 'exunixn' => [IO::Compress::Base::Common::Parse_any, undef],
+ 'extattr' => [IO::Compress::Base::Common::Parse_any,
$Compress::Raw::Zlib::gzip_os_code == 3
? 0100644 << 16
: 0],
- 'OS_Code' => [0, 1, Parse_unsigned, $Compress::Raw::Zlib::gzip_os_code],
+ 'os_code' => [IO::Compress::Base::Common::Parse_unsigned, $Compress::Raw::Zlib::gzip_os_code],
- 'TextFlag' => [0, 1, Parse_boolean, 0],
- 'ExtraFieldLocal' => [0, 1, Parse_any, undef],
- 'ExtraFieldCentral'=> [0, 1, Parse_any, undef],
+ 'textflag' => [IO::Compress::Base::Common::Parse_boolean, 0],
+ 'extrafieldlocal' => [IO::Compress::Base::Common::Parse_any, undef],
+ 'extrafieldcentral'=> [IO::Compress::Base::Common::Parse_any, undef],
# Lzma
- 'Preset' => [0, 1, Parse_unsigned, 6],
- 'Extreme' => [1, 1, Parse_boolean, 0],
+ 'preset' => [IO::Compress::Base::Common::Parse_unsigned, 6],
+ 'extreme' => [IO::Compress::Base::Common::Parse_boolean, 0],
# For internal use only
- 'Sparse' => [0, 1, Parse_unsigned, 0],
+ 'sparse' => [IO::Compress::Base::Common::Parse_unsigned, 0],
- @Bzip2,
- );
+ IO::Compress::RawDeflate::getZlibParams(),
+ defined $IO::Compress::Bzip2::VERSION
+ ? IO::Compress::Bzip2::getExtraParams()
+ : ()
+
+
+ );
+
+sub getExtraParams
+{
+ return %PARAMS ;
}
sub getInverseClass
@@ -726,16 +724,16 @@ sub getFileInfo
my $params = shift;
my $filename = shift ;
- if (isaScalar($filename))
+ if (IO::Compress::Base::Common::isaScalar($filename))
{
- $params->value(Zip64 => 1)
- if isGeMax32 length (${ $filename }) ;
+ $params->setValue(zip64 => 1)
+ if IO::Compress::Base::Common::isGeMax32 length (${ $filename }) ;
return ;
}
my ($mode, $uid, $gid, $size, $atime, $mtime, $ctime) ;
- if ( $params->parsed('StoreLinks') )
+ if ( $params->parsed('storelinks') )
{
($mode, $uid, $gid, $size, $atime, $mtime, $ctime)
= (lstat($filename))[2, 4,5,7, 8,9,10] ;
@@ -746,40 +744,40 @@ sub getFileInfo
= (stat($filename))[2, 4,5,7, 8,9,10] ;
}
- $params->value(TextFlag => -T $filename )
- if ! $params->parsed('TextFlag');
+ $params->setValue(textflag => -T $filename )
+ if ! $params->parsed('textflag');
- $params->value(Zip64 => 1)
- if isGeMax32 $size ;
+ $params->setValue(zip64 => 1)
+ if IO::Compress::Base::Common::isGeMax32 $size ;
- $params->value('Name' => $filename)
- if ! $params->parsed('Name') ;
+ $params->setValue('name' => $filename)
+ if ! $params->parsed('name') ;
- $params->value('Time' => $mtime)
- if ! $params->parsed('Time') ;
+ $params->setValue('time' => $mtime)
+ if ! $params->parsed('time') ;
- if ( ! $params->parsed('exTime'))
+ if ( ! $params->parsed('extime'))
{
- $params->value('MTime' => $mtime) ;
- $params->value('ATime' => $atime) ;
- $params->value('CTime' => undef) ; # No Creation time
+ $params->setValue('mtime' => $mtime) ;
+ $params->setValue('atime' => $atime) ;
+ $params->setValue('ctime' => undef) ; # No Creation time
# TODO - see if can fillout creation time on non-Unix
}
# NOTE - Unix specific code alert
- if (! $params->parsed('ExtAttr'))
+ if (! $params->parsed('extattr'))
{
use Fcntl qw(:mode) ;
my $attr = $mode << 16;
$attr |= ZIP_A_RONLY if ($mode & S_IWRITE) == 0 ;
$attr |= ZIP_A_DIR if ($mode & S_IFMT ) == S_IFDIR ;
- $params->value('ExtAttr' => $attr);
+ $params->setValue('extattr' => $attr);
}
- $params->value('want_exUnixN', [$uid, $gid]);
- $params->value('UID' => $uid) ;
- $params->value('GID' => $gid) ;
+ $params->setValue('want_exunixn', [$uid, $gid]);
+ $params->setValue('uid' => $uid) ;
+ $params->setValue('gid' => $gid) ;
}
@@ -936,19 +934,20 @@ section.
use IO::Compress::Zip qw(zip $ZipError) ;
- zip $input => $output [,OPTS]
+ zip $input_filename_or_reference => $output_filename_or_reference [,OPTS]
or die "zip failed: $ZipError\n";
The functional interface needs Perl5.005 or better.
=head2 zip $input => $output [, OPTS]
-C<zip> expects at least two parameters, C<$input> and C<$output>.
+C<zip> expects at least two parameters,
+C<$input_filename_or_reference> and C<$output_filename_or_reference>.
-=head3 The C<$input> parameter
+=head3 The C<$input_filename_or_reference> parameter
-The parameter, C<$input>, is used to define the source of
-the uncompressed data.
+The parameter, C<$input_filename_or_reference>, is used to define the
+source of the uncompressed data.
It can take one of the following forms:
@@ -956,25 +955,25 @@ It can take one of the following forms:
=item A filename
-If the C<$input> parameter is a simple scalar, it is assumed to be a
-filename. This file will be opened for reading and the input data
-will be read from it.
+If the <$input_filename_or_reference> parameter is a simple scalar, it is
+assumed to be a filename. This file will be opened for reading and the
+input data will be read from it.
=item A filehandle
-If the C<$input> parameter is a filehandle, the input data will be
-read from it.
-The string '-' can be used as an alias for standard input.
+If the C<$input_filename_or_reference> parameter is a filehandle, the input
+data will be read from it. The string '-' can be used as an alias for
+standard input.
=item A scalar reference
-If C<$input> is a scalar reference, the input data will be read
-from C<$$input>.
+If C<$input_filename_or_reference> is a scalar reference, the input data
+will be read from C<$$input_filename_or_reference>.
=item An array reference
-If C<$input> is an array reference, each element in the array must be a
-filename.
+If C<$input_filename_or_reference> is an array reference, each element in
+the array must be a filename.
The input data will be read from each file in turn.
@@ -983,72 +982,80 @@ contains valid filenames before any data is compressed.
=item An Input FileGlob string
-If C<$input> is a string that is delimited by the characters "<" and ">"
-C<zip> will assume that it is an I<input fileglob string>. The
-input is the list of files that match the fileglob.
+If C<$input_filename_or_reference> is a string that is delimited by the
+characters "<" and ">" C<zip> will assume that it is an
+I<input fileglob string>. The input is the list of files that match the
+fileglob.
See L<File::GlobMapper|File::GlobMapper> for more details.
=back
-If the C<$input> parameter is any other type, C<undef> will be returned.
+If the C<$input_filename_or_reference> parameter is any other type,
+C<undef> will be returned.
-In addition, if C<$input> is a simple filename, the default values for
+In addition, if C<$input_filename_or_reference> is a simple filename,
+the default values for
the C<Name>, C<Time>, C<TextFlag>, C<ExtAttr>, C<exUnixN> 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>, C<TextFlag>, C<ExtAttr>, C<exUnixN> and C<exTime> options or by setting the
C<Minimal> parameter.
-=head3 The C<$output> parameter
+=head3 The C<$output_filename_or_reference> parameter
-The parameter C<$output> is used to control the destination of the
-compressed data. This parameter can take one of these forms.
+The parameter C<$output_filename_or_reference> is used to control the
+destination of the compressed data. This parameter can take one of
+these forms.
=over 5
=item A filename
-If the C<$output> parameter is a simple scalar, it is assumed to be a
-filename. This file will be opened for writing and the compressed
-data will be written to it.
+If the C<$output_filename_or_reference> parameter is a simple scalar, it is
+assumed to be a filename. This file will be opened for writing and the
+compressed data will be written to it.
=item A filehandle
-If the C<$output> parameter is a filehandle, the compressed data
-will be written to it.
-The string '-' can be used as an alias for standard output.
+If the C<$output_filename_or_reference> parameter is a filehandle, the
+compressed data will be written to it. The string '-' can be used as
+an alias for standard output.
=item A scalar reference
-If C<$output> is a scalar reference, the compressed data will be
-stored in C<$$output>.
+If C<$output_filename_or_reference> is a scalar reference, the
+compressed data will be stored in C<$$output_filename_or_reference>.
=item An Array Reference
-If C<$output> is an array reference, the compressed data will be
-pushed onto the array.
+If C<$output_filename_or_reference> is an array reference,
+the compressed data will be pushed onto the array.
=item An Output FileGlob
-If C<$output> is a string that is delimited by the characters "<" and ">"
-C<zip> will assume that it is an I<output fileglob string>. The
-output is the list of files that match the fileglob.
+If C<$output_filename_or_reference> is a string that is delimited by the
+characters "<" and ">" C<zip> will assume that it is an
+I<output fileglob string>. The output is the list of files that match the
+fileglob.
-When C<$output> is an fileglob string, C<$input> must also be a fileglob
-string. Anything else is an error.
+When C<$output_filename_or_reference> is an fileglob string,
+C<$input_filename_or_reference> must also be a fileglob string. Anything
+else is an error.
See L<File::GlobMapper|File::GlobMapper> for more details.
=back
-If the C<$output> parameter is any other type, C<undef> will be returned.
+If the C<$output_filename_or_reference> parameter is any other type,
+C<undef> will be returned.
=head2 Notes
-When C<$input> maps to multiple files/buffers and C<$output> is a single
+When C<$input_filename_or_reference> maps to multiple files/buffers and
+C<$output_filename_or_reference> is a single
file/buffer the input files/buffers will each be stored
-in C<$output> as a distinct entry.
+in C<$output_filename_or_reference> as a distinct entry.
=head2 Optional Parameters
@@ -1463,7 +1470,8 @@ The default is 1.
=item C<< Zip64 => 0|1 >>
Create a Zip64 zip file/buffer. This option is used if you want
-to store files larger than 4 Gig.
+to store files larger than 4 Gig or store more than 64K files in a single
+zip archive..
C<Zip64> will be automatically set, as needed, if working with the one-shot
interface when the input is either a filename or a scalar reference.
@@ -1489,6 +1497,7 @@ the file contains text.
The default is 0.
=item C<< ExtraFieldLocal => $data >>
+
=item C<< ExtraFieldCentral => $data >>
The C<ExtraFieldLocal> option is used to store additional metadata in the
@@ -1944,7 +1953,7 @@ See the Changes file.
=head1 COPYRIGHT AND LICENSE
-Copyright (c) 2005-2012 Paul Marquess. All rights reserved.
+Copyright (c) 2005-2013 Paul Marquess. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.