Subject: | addFile fails on noexistent file |
Date: | Tue, 3 Dec 2013 13:02:01 +0000 |
To: | "bug-Archive-Zip [...] rt.cpan.org" <bug-Archive-Zip [...] rt.cpan.org> |
From: | "Rieder Martin (INFRA.SBM)" <Martin.Rieder [...] oebb.at> |
Module: Archive::Zip::Archive
use methodes of $newMember only if $newMember is defined, as it was in version 1.28
This fix worked for me:
sub addFile {
my $self = shift;
my ( $fileName, $newName, $compressionLevel );
if ( ref( $_[0] ) eq 'HASH' ) {
$fileName = $_[0]->{filename};
$newName = $_[0]->{zipName};
$compressionLevel = $_[0]->{compressionLevel};
}
else {
( $fileName, $newName, $compressionLevel ) = @_;
}
if ( $^O eq 'MSWin32' && $Archive::Zip::UNICODE ) {
$fileName = Win32::GetANSIPathName($fileName);
}
my $newMember = $self->ZIPMEMBERCLASS->newFromFile( $fileName, $newName );
$newMember->desiredCompressionLevel($compressionLevel) if defined($newMember);
if ( $self->{'storeSymbolicLink'} && -l $fileName ) {
my $newMember = $self->ZIPMEMBERCLASS->newFromString(readlink $fileName, $newName);
# For symbolic links, External File Attribute is set to 0xA1FF0000 by Info-ZIP
$newMember->{'externalFileAttributes'} = 0xA1FF0000;
$self->addMember($newMember);
} else {
$self->addMember($newMember) if defined($newMember);
}
if ( $^O eq 'MSWin32' && $Archive::Zip::UNICODE ) {
$newMember->{'fileName'} = encode_utf8( Win32::GetLongPathName($fileName) );
}
return $newMember;
}
Regards,
Martin Rieder
-----------------------------------------------------------------------------
ÖBB-Infrastruktur AG, Praterstern 3, 1020 Wien
FN 71396w HG Wien | DVR 0063533 | UID ATU 16210507
Diese Nachricht könnte vertrauliche Informationen enthalten. Sind Sie nicht der richtige Empfänger, so informieren Sie bitte den Absender und löschen Sie diese Nachricht. Die unbefugte Nutzung oder Weitergabe dieser Nachricht ist nicht erlaubt.