Bug in IO::Uncompress::Unzip::nextStream() ?




Recently I've been using the IO::Uncompress::Unzip module to
manually unzip archived files out of *.zip files.

After unzipping one file, I call $z->nextStream(), and if it
returns 1, I loop back and unzip the next file.

However, I've discovered that $z->nextStream() seems to always
return 1, even though the "perldoc IO::Uncompress::Unzip"
documentation explicitly says that nextStream() returns 1 if a new
stream was found, and 0 if none was found.

This behavior happens to me using both Strawberry Perl 5.10 (on
Windows 7), and Perl 5.12.2 (built for alpha-netbsd-thread-multi).

Here is a test script that reproduces what I'm seeing. To use it,
create a *.zip file with a small number of archive files, and then
pass in the *.zip file as its sole argument. You will see the last
file in the *.zip archive repeated endlessly.

# File: test_unzip.pl
# Purpose: To demonstrate the correctness of the
# IO::Uncompress::Unzip::nextStream() method.

use strict;
use warnings;

die "Usage: perl $0 <file.zip>\n" unless @ARGV == 1;
my ($zipFile) = @ARGV;

use IO::Uncompress::Unzip qw(unzip $UnzipError);

my $z = new IO::Uncompress::Unzip $zipFile
or die "unzip failed: $UnzipError\n";

print "'$zipFile' contains the following file(s):\n";

my $numFiles = 0;

my $data = $z->getHeaderInfo();
print " $numFiles. $data->{Name}\n";
while ($z->nextStream() == 1); # Always returns 1,
# and so will loop forever!


If I run these commands:

touch a b c
zip blah.zip a b c
perl test_unzip.pl blah.zip

I see the following output:

'blah.zip' contains the following file(s):
1. a
2. b
3. c
4. c
5. c
6. c
7. c
8. c
9. c
10. c
11. c

.... and so on.

So is what I'm seeing a bug in IO::Uncompress::Unzip, or am I using
nextStream() incorrectly? And if I do happen to be using it
incorrectly, how do I know how when I've reached the last stream? (Or
how can I know how many streams there are, so I can know when to stop
looking for more?)


-- Jean-Luc




This issue has been fixed in 2.030 of the this module.

Thanks. Because of what you said, I installed version 2.030 of
IO::Uncompress::Unzip, and now ::nextStream() works as documented in
my test program.

Thanks again.

-- Jean-Luc

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question