Skip Menu |
 

This queue is for tickets about the Archive-Zip CPAN distribution.

Report information
The Basics
Id: 42423
Status: open
Priority: 0/
Queue: Archive-Zip

People
Owner: Nobody in particular
Requestors: JDB [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.26
Fixed in: (no value)



Subject: Can't chdir() after reading a zip file with relative pathname
Download (untitled) / with headers
text/plain 817b
The following code does not work: my $file = "./foo/bar.zip"; my $zip = Archive::Zip->new; $zip->read($file) == Archive::Zip::AZ_OK() or die "Can't read zip file $file"; my $cwd = Cwd::cwd; chdir($dir) or die "Can't chdir into $dir: $!"; $zip->extractTree() == Archive::Zip::AZ_OK() or die "Can't unzip $file into $dir"; chdir($cwd) or die "Can't chdir into $cwd: $!"; The extractTree() call would print an error like this: IO error: Can't open ./foo/bar.zip : No such file or directory This happens because Archive::Zip doesn't keep a filehandle open in the read() method but stores the filename and later tries to re-open it when the current directory has changed. You can work around it by only passing absolute filenames to read(): $zip->read(Cwd::abs_path($file));
Subject: Re: [rt.cpan.org #42423] Can't chdir() after reading a zip file with relative pathname
Date: Thu, 15 Jan 2009 11:24:31 +1100
To: bug-Archive-Zip [...] rt.cpan.org
From: Adam Kennedy <adamkennedybackup [...] gmail.com>
Download (untitled) / with headers
text/plain 1.3k
As an aside, if you want to get commit to fix this or anything else in http://svn.ali.as/cpan/trunk let me know and I'll add it. Adam K 2009/1/15 Jan Dubois via RT <bug-Archive-Zip@rt.cpan.org>: Show quoted text
> Wed Jan 14 18:04:05 2009: Request 42423 was acted upon. > Transaction: Ticket created by JDB > Queue: Archive-Zip > Subject: Can't chdir() after reading a zip file with relative pathname > Broken in: 1.26 > Severity: Normal > Owner: Nobody > Requestors: JDB@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=42423 > > > > The following code does not work: > > my $file = "./foo/bar.zip"; > my $zip = Archive::Zip->new; > $zip->read($file) == Archive::Zip::AZ_OK() or die "Can't read zip > file $file"; > my $cwd = Cwd::cwd; > chdir($dir) or die "Can't chdir into $dir: $!"; > $zip->extractTree() == Archive::Zip::AZ_OK() or die "Can't unzip > $file into $dir"; > chdir($cwd) or die "Can't chdir into $cwd: $!"; > > The extractTree() call would print an error like this: > > IO error: Can't open ./foo/bar.zip : No such file or directory > > This happens because Archive::Zip doesn't keep a filehandle open in > the read() method but stores the filename and later tries to re-open > it when the current directory has changed. > > You can work around it by only passing absolute filenames to read(): > > $zip->read(Cwd::abs_path($file)); > >


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.