Subject: | Explicitly tell Archive::Zip where to put the files |
From d4f97631f89d6f2c5d50b343a5f64d43770efdaf Mon Sep 17 00:00:00 2001
From: brian d foy <brian.d.foy@gmail.com>
Date: Fri, 13 Feb 2009 20:22:35 -0600
Subject: [PATCH] * Tell Archive::Zip's extractMember where to put it.
This was an odd case to track down, and I haven't come up with
a small test case to demonstrate it.
In my BackPAN indexing, Archive::Zip was extracting things
in my script's directory instead of the current working directory.
I traced this back through Archive::Zip::_asLocalName which
eventually calls File::Spec::Win32::rel2abs which on Windows might
call Cwd::getdcwd. getdcwd returns the wrong directory in my
case, even though I think I'm on the same drive.
To fix this, I pass the optional second argument to
extractMember using the cwd from Archive::Extract.
---
lib/Archive/Extract.pm | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/Archive/Extract.pm b/lib/Archive/Extract.pm
index 7c5df63..69e023c 100644
--- a/lib/Archive/Extract.pm
+++ b/lib/Archive/Extract.pm
@@ -1031,7 +1031,8 @@ sub _unzip_az {
for my $member ($zip->members) {
push @files, $member->{fileName};
- unless( $zip->extractMember($member) == &Archive::Zip::AZ_OK )
{
+ unless( $zip->extractMember($member,
+ File::Spec->catfile(cwd(), $files[-1]) ) ==
&Archive::Zip::AZ_OK ) {
return $self->_error(loc("Extraction of '%1' from '%2'
failed",
$member->{fileName}, $self->archive ));
}
--
1.6.0.4