When I use Archive::Zip to zip a list of files, I cannot open the resulting zip file because it is "blocked". Does anybody know a way around this? I'm using the exact example provided for zipping files using this module... The zip has a size, but when I try to preview it.. it appears to be empty.
Update:
I've used this code prior to sp2 update, and know that it works.However, if you think I'm doing something wrong, by all means let me know. Like I said, it seems to be zipping because the Zip file which is created has a size on disk. The problem comes when I try to view it's contents through windows.
sub ZipFiles
{
use Archive::Zip qw(:ERROR_CODES :CONSTANTS);
my $ret = 0;
my @msg = ();
if ( @_ > 1 ) {
my $fileName = shift;
my @fileNames = @_;
$fileName =~ s/\.zip//;
my $zip = Archive::Zip->new();
foreach my $memberName (@fileNames) {
if (-d $memberName ) {
push(@msg, "Error: Could not add directory $memberName
+ to zip file.")
if $zip->addTree( $memberName, $memberName ) != AZ
+_OK;
}
else {
$zip->addFile( $memberName )
or push(@msg, "Error adding file $memberName\n")
+;
}
}
if ($zip->writeToFileNamed( "$fileName.zip" ) != AZ_OK ) {
$ret = 1;
push (@msg, "Error: Zip file could not be created. A write
+ error has occured. Verify that specified directory is correct.");
}
}
else {
$ret = 1;
push(@msg, "Error: Number of arguments does not match specifie
+d amount.");
}
if ( $ret == 0 ) {
@msg = ();
push(@msg, "Files have been zipped successfully.");
}
return wantarray ? ($ret, @msg) : $ret;
}
I am using version 1.16. I am using ActiveState 5.8.6.