Archive-Zip
view release on metacpan or search on metacpan
lib/Archive/Zip/Member.pm view on Meta::CPAN
sub compressionMethod {
shift->{'compressionMethod'};
}
sub desiredCompressionMethod {
my $self = shift;
my $newDesiredCompressionMethod =
(ref($_[0]) eq 'HASH') ? shift->{compressionMethod} : shift;
my $oldDesiredCompressionMethod = $self->{'desiredCompressionMethod'};
if (defined($newDesiredCompressionMethod)) {
$self->{'desiredCompressionMethod'} = $newDesiredCompressionMethod;
if ($newDesiredCompressionMethod == COMPRESSION_STORED) {
$self->{'desiredCompressionLevel'} = 0;
$self->{'bitFlag'} &= ~GPBF_HAS_DATA_DESCRIPTOR_MASK
if $self->uncompressedSize() == 0;
} elsif ($oldDesiredCompressionMethod == COMPRESSION_STORED) {
$self->{'desiredCompressionLevel'} = COMPRESSION_LEVEL_DEFAULT;
}
}
return $oldDesiredCompressionMethod;
}
sub desiredCompressionLevel {
my $self = shift;
my $newDesiredCompressionLevel =
(ref($_[0]) eq 'HASH') ? shift->{compressionLevel} : shift;
my $oldDesiredCompressionLevel = $self->{'desiredCompressionLevel'};
if (defined($newDesiredCompressionLevel)) {
$self->{'desiredCompressionLevel'} = $newDesiredCompressionLevel;
$self->{'desiredCompressionMethod'} = (
$newDesiredCompressionLevel
? COMPRESSION_DEFLATED
: COMPRESSION_STORED
);
}
return $oldDesiredCompressionLevel;
}
sub fileName {
my $self = shift;
my $newName = shift;
if (defined $newName) {
$newName =~ y{\\/}{/}s; # deal with dos/windoze problems
$self->{'fileName'} = $newName;
}
return $self->{'fileName'};
}
sub fileNameAsBytes {
my $self = shift;
my $bytes = $self->{'fileName'};
if($self->{'bitFlag'} & 0x800){
$bytes = Encode::encode_utf8($bytes);
}
return $bytes;
}
sub lastModFileDateTime {
my $modTime = shift->{'lastModFileDateTime'};
$modTime =~ m/^(\d+)$/; # untaint
return $1;
}
sub lastModTime {
my $self = shift;
return _dosToUnixTime($self->lastModFileDateTime());
}
sub setLastModFileDateTimeFromUnix {
my $self = shift;
my $time_t = shift;
$self->{'lastModFileDateTime'} = _unixToDosTime($time_t);
}
sub internalFileAttributes {
shift->{'internalFileAttributes'};
}
sub externalFileAttributes {
shift->{'externalFileAttributes'};
}
# Convert UNIX permissions into proper value for zip file
# Usable as a function or a method
sub _mapPermissionsFromUnix {
my $self = shift;
my $mode = shift;
my $attribs = $mode << 16;
# Microsoft Windows Explorer needs this bit set for directories
if ($mode & DIRECTORY_ATTRIB) {
$attribs |= 16;
}
return $attribs;
# TODO: map more MS-DOS perms
}
# Convert ZIP permissions into Unix ones
#
# This was taken from Info-ZIP group's portable UnZip
# zipfile-extraction program, version 5.50.
# http://www.info-zip.org/pub/infozip/
#
# See the mapattr() function in unix/unix.c
# See the attribute format constants in unzpriv.h
#
# XXX Note that there's one situation that is not implemented
# yet that depends on the "extra field."
sub _mapPermissionsToUnix {
my $self = shift;
my $format = $self->{'fileAttributeFormat'};
my $attribs = $self->{'externalFileAttributes'};
my $mode = 0;
if ($format == FA_AMIGA) {
$attribs = $attribs >> 17 & 7; # Amiga RWE bits
( run in 1.322 second using v1.01-cache-2.11-cpan-39bf76dae61 )