I was attempting to use the following code from Archive:Zip examples on Windows:
# Example of how to compute compressed sizes
# $Revision: 1.2 $
use strict;
use Archive::Zip qw(:ERROR_CODES);
require File::Spec::Win32;
my $zip = Archive::Zip->new();
my $blackHoleDevice = File::Spec::Win32->devnull();
$zip->addFile($_) foreach (<*.pl>);
# Write and throw the data away.
# after members are written, the writeOffset will be set
# to the compressed size.
$zip->writeToFileNamed($blackHoleDevice);
my $totalSize = 0;
my $totalCompressedSize = 0;
foreach my $member ($zip->members())
{
$totalSize += $member->uncompressedSize;
$totalCompressedSize += $member->_writeOffset;
print "Member ", $member->externalFileName,
" size=", $member->uncompressedSize,
", writeOffset=", $member->_writeOffset,
", compressed=", $member->compressedSize,
"\n";
}
print "Total Size=", $totalSize, ", total compressed=", $totalCompress
+edSize, "\n";
$zip->writeToFileNamed('test.zip');
However, while it worked on Linux, OSX, it was a failure on Windows. BTW: while stepping through the debugger i saw that the scalar $blackHoleDevice was set to 'nul' not the usual Windows /dev/null device 'NUL'. However even it it was then set to 'NUL' it still did not work. When $blackHoleDevice was replaced by an actual file name it worked fine, but one assumes that the use of /dev/null was used to avoid the actual creation of a file.
Question: is this just windows or me?