Subject: | IO::Uncompress::Unzip fails to properly read file in subdirectory |
Date: | Tue, 6 May 2008 19:03:00 -0400 |
To: | bug-IO-Compress-Zlib [...] rt.cpan.org |
From: | "Dean Hoover" <dhoover [...] fermata-international.com> |
Hello,
I believe I found a bug in IO::Uncompress::Unzip with regard to files in
subdirectories.
I am running perl 5.8.8 and apparently the version number of the module is
2.005.
My operating system is reported through uname -a as:
Linux fermata-international.com 2.6.18-5-686 #1 SMP Tue Dec 18 21:24:20 UTC
2007 i686 GNU/Linux
An example program follows:
#!/usr/bin/perl
use IO::Uncompress::Unzip qw($UnzipError);
my $zipFile = $ARGV[0];
my $uzip = new IO::Uncompress::Unzip $zipFile or die "can't open data:
$UnzipError";
my $status;
for ($status = 1; not $uzip->eof(); $status = $uzip->nextStream())
{
my $name = $uzip->getHeaderInfo()->{Name};
print "reading $name\n";
my $data;
my $buffer;
while (($status = $uzip->read($buffer)) > 0)
{
print " $status bytes\n";
$data .= $buffer;
}
print "$name size = ", length($data), "\n";
last unless $status == 0;
}
die "error in zip processing: $!\n" if $status < 0;
============
I created a zip file on the same OS using the zip -r command with in a
directory
containing:
- a file named 'a.html'
- a subdirectory named 'x'
- a file in subdirectory x, that is identical to file a.html named 'y.html'
When I run the program, I get the following output:
reading a.html
113 bytes
a.html size = 113
reading x/
x/ size = 0
reading x/y.html
98 bytes
x/y.html size = 98
Checking the file system using ls -lR, I find that a.html is reported as the
correct size
but x/y.html is incorrect. Furthermore, if I print the contents of the
buffer, a.html looks fine
and x/y.html is scrambled.
I hope this helps in debugging the problem. If you have any further
questions to not hestiate to
send an email.
Thanks for your efforts, they are appreciated.
Dean Hoover