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

Discussion in 'Perl Misc' started by jl_post@hotmail.com, Sep 30, 2010.

  1. Guest

    Hi,

    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.


    #!/usr/bin/perl
    # 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;

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

    __END__

    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?)

    Thanks,

    -- Jean-Luc
    , Sep 30, 2010
    #1
    1. Advertising

  2. Guest

    On Sep 30, 4:01 pm, "Paul Marquess \(\)"
    wrote:
    >
    > 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
    , Oct 4, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. chattycow
    Replies:
    4
    Views:
    3,763
    Chris Uppal
    May 16, 2006
  2. chattycow
    Replies:
    11
    Views:
    3,886
    Dale King
    May 22, 2006
  3. =?Utf-8?B?SGFycnkgS2Vjaw==?=

    Compress data on server and uncompress on client?

    =?Utf-8?B?SGFycnkgS2Vjaw==?=, May 22, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    478
  4. Rocky Zhou
    Replies:
    0
    Views:
    572
    Rocky Zhou
    Apr 2, 2007
  5. Replies:
    3
    Views:
    278
    Graeme Glass
    May 23, 2007
Loading...

Share This Page