changeset 98:62a96d51bf94

Fixed ZipArchive.extract with relative paths on Windows
author Oleg Oshmyan <chortos@inbox.lv>
date Wed, 02 Mar 2011 19:52:03 +0000
parents bbf9c434fa57
children 9b41934b2e95
files files.py
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/files.py	Wed Mar 02 19:00:57 2011 +0000
+++ b/files.py	Wed Mar 02 19:52:03 2011 +0000
@@ -108,16 +108,16 @@
 			self.file = zipfile.ZipFile(path)
 		
 		def extract(self, name, target):
+			member = self.file.getinfo(name)
+			# FIXME: 2.5 lacks ZipFile.extract
 			if os.path.isabs(target):
 				# To my knowledge, this is as portable as it gets
 				path = os.path.join(os.path.splitdrive(target)[0], os.path.sep)
+				member.filename = os.path.relpath(target, path)
+				self.file.extract(member, path)
 			else:
-				path = None
-			
-			member = self.file.getinfo(name)
-			member.filename = os.path.relpath(target, path)
-			# FIXME: 2.5 lacks ZipFile.extract
-			self.file.extract(member, path)
+				member.filename = os.path.relpath(target)
+				self.file.extract(member)
 		
 		def open(self, name):
 			return self.file.open(name, 'rU')