summaryrefslogtreecommitdiff
path: root/fs/zipfs.py
diff options
context:
space:
mode:
authorwillmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f>2011-05-26 10:45:14 +0000
committerwillmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f>2011-05-26 10:45:14 +0000
commitc68d276e473a7414f4aa2c8a7aba2eea5ae6f129 (patch)
treee763bae5293f178c01a02a85b665ebc066346553 /fs/zipfs.py
parentaf06455f81c6c08a948d84ce75150c035cff9f4d (diff)
downloadpyfilesystem-c68d276e473a7414f4aa2c8a7aba2eea5ae6f129.tar.gz
Fix from Andrew for large zip files
git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@708 67cdc799-7952-0410-af00-57a81ceafa0f
Diffstat (limited to 'fs/zipfs.py')
-rw-r--r--fs/zipfs.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/zipfs.py b/fs/zipfs.py
index 55eaf75..c337ee5 100644
--- a/fs/zipfs.py
+++ b/fs/zipfs.py
@@ -111,6 +111,9 @@ class ZipFS(FS):
if isinstance(zip_file, basestring):
zip_file = os.path.expanduser(os.path.expandvars(zip_file))
zip_file = os.path.normpath(os.path.abspath(zip_file))
+ self._zip_file_string = True
+ else:
+ self._zip_file_string = False
try:
self.zf = ZipFile(zip_file, mode, compression_type, allow_zip_64)
@@ -181,7 +184,10 @@ class ZipFS(FS):
path=path,
msg="1 Zip file must be opened for reading ('r') or appending ('a')")
try:
- contents = self.zf.read(path.encode(self.encoding))
+ if hasattr(self.zf, 'open') and self._zip_file_string:
+ return self.zf.open(path.encode(self.encoding))
+ else:
+ contents = self.zf.read(path.encode(self.encoding))
except KeyError:
raise ResourceNotFoundError(path)
return StringIO(contents)