|
Packit |
0bf95d |
#!/usr/bin/perl
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
use strict;
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
BEGIN {
|
|
Packit |
0bf95d |
$| = 1;
|
|
Packit |
0bf95d |
$^W = 1;
|
|
Packit |
0bf95d |
}
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
use Test::More tests => 4;
|
|
Packit |
0bf95d |
use File::Spec;
|
|
Packit |
0bf95d |
use File::Path;
|
|
Packit |
0bf95d |
use Archive::Zip qw(:CONSTANTS);
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
use lib 't';
|
|
Packit |
0bf95d |
use common;
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
#101240: Possible issue with zero length files on Win32 when UNICODE is enabled
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
my $test_dir = File::Spec->catdir(TESTDIR, "empty");
|
|
Packit |
0bf95d |
my $input_file = File::Spec->catfile($test_dir, "empty.zip");
|
|
Packit |
0bf95d |
mkpath($test_dir);
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
{
|
|
Packit |
0bf95d |
# Create a zip file that contains a member where compressed size is 0
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
my $zip = Archive::Zip->new();
|
|
Packit |
0bf95d |
my $string_member = $zip->addString( '', 'fred' );
|
|
Packit |
0bf95d |
$string_member->desiredCompressionMethod( COMPRESSION_STORED );
|
|
Packit |
0bf95d |
$zip->writeToFileNamed($input_file) ;
|
|
Packit |
0bf95d |
}
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
for my $unicode (0, 1)
|
|
Packit |
0bf95d |
{
|
|
Packit |
0bf95d |
local $Archive::Zip::UNICODE = $unicode;
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
my $zip = Archive::Zip->new();
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
$zip->read($input_file);
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
my $test_file = File::Spec->catfile($test_dir, "test_file$unicode");
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
$zip->memberNamed("fred")->extractToFileNamed($test_file);
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
# TEST
|
|
Packit |
0bf95d |
ok -e $test_file, "[UNICODE=$unicode] output file exists";
|
|
Packit |
0bf95d |
is -s $test_file, 0, "[UNICODE=$unicode] output file is empty";
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
# Clean up.
|
|
Packit |
0bf95d |
#unlink $test_file;
|
|
Packit |
0bf95d |
}
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
#rmtree($test_dir);
|