metalgear119 has asked for the wisdom of the Perl Monks concerning the following question:

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.

Replies are listed 'Best First'.
Re: Archive::Zip Problems under windows sp2
by Steve_p (Priest) on Jul 29, 2005 at 02:32 UTC

    Could you please provide some example code for what you're trying to do? Without it, I can't really see what's happening. Also, what version of Archive::Zip and Perl are you using?

Re: Archive::Zip Problems under windows sp2
by wufnik (Friar) on Jul 29, 2005 at 06:55 UTC
    hiya

    i'd bet that the module is doing it's job fine, and that some peculiar SP2 feature is the reason for the peculiar behaviour above.

    if this is the case, and you do indeed find that -s $filename.zip of the above is non-zero, then i would suggest attempting to unzip it, in a separate script, using Archive::Zip. if the unzipping works, perl has done it's job properly, and you can check the SP2 experts for their knowledge on zip file problems.

    alternately, if you have cygwin, you could check out the unzip tool to examine the archive, to do the same thing.

    ...wufnik

    -- in the world of the mules there are no rules --