pmqs / Archive-Zip-SimpleZip

Perl5 interface to read/write Zip files
4 stars 5 forks source link

Can't extract after read content #3

Closed victor-bert closed 5 years ago

victor-bert commented 5 years ago

When i try extract file after read his content, file extracted is empty I guess need to seek curent position of file, but Member hasn't this method.

pmqs commented 5 years ago

@victor-bert Can you show me the code you were using?

pmqs commented 5 years ago

Is this the issue?

First create a zip file

# echo abcd | zip /tmp/x.zip -
updating: - (stored 0%)

The run this code

use warnings;
use strict;

use Archive::Zip::SimpleUnzip qw($SimpleUnzipError) ;
my $zipfile = "/tmp/x.zip";
my $z = new Archive::Zip::SimpleUnzip $zipfile
    or die "Cannot open zip file: $SimpleUnzipError\n" ;
while (my $member = $z->next())
{

    my $name = $member->name();
    print "member $name\n" ;

    my $fh = $member->open();
    while (<$fh>)
    {
    }

    $member->extract("out") 
        or die "cannot extact: $SimpleUnzipError\n";
}

And finally note that the file out is empty.

# ls -l out
-rw-rw-r-- 1 root root 0 Oct 24 16:45 out
victor-bert commented 5 years ago

@victor-bert Can you show me the code you were using?

Here my code:

use feature qw/say/;
my $zip = new Archive::Zip::SimpleUnzip($zipfile)
    or die "Cannot open zip file: $SimpleUnzipError\n" ;
my $member = $zip->member('example.txt');
say $member->content;  # need to check content
$member->extract($path);  # inside extract() content is empty, file extracted empty
pmqs commented 5 years ago

Thanks. I see what the issue is.

pmqs commented 5 years ago

Fixed in change 76943104cfce9e3ee4a4772b115fdb89faefa6fc