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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.