summaryrefslogtreecommitdiffstats
path: root/Lib/zipfile.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-09-23 19:40:23 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-09-23 19:40:23 (GMT)
commit46a34924e45d7a0a4d0e31bdc54eef30c0afa44e (patch)
tree6a8b2bf6a246007ceee7f5779224d18d76a81d7e /Lib/zipfile.py
parent026a399bf9b7d747cb04c69134e8e953aebc9760 (diff)
downloadcpython-46a34924e45d7a0a4d0e31bdc54eef30c0afa44e.zip
cpython-46a34924e45d7a0a4d0e31bdc54eef30c0afa44e.tar.gz
cpython-46a34924e45d7a0a4d0e31bdc54eef30c0afa44e.tar.bz2
Issue #20912: Now directories added to ZIP file have correct Unix and MS-DOS
directory attributes.
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r--Lib/zipfile.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index e5b7818..7e07f11 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -1356,6 +1356,7 @@ class ZipFile:
zinfo.file_size = 0
zinfo.compress_size = 0
zinfo.CRC = 0
+ zinfo.external_attr |= 0x10 # MS-DOS directory flag
self.filelist.append(zinfo)
self.NameToInfo[zinfo.filename] = zinfo
self.fp.write(zinfo.FileHeader(False))
@@ -1416,7 +1417,11 @@ class ZipFile:
zinfo = ZipInfo(filename=zinfo_or_arcname,
date_time=time.localtime(time.time())[:6])
zinfo.compress_type = self.compression
- zinfo.external_attr = 0o600 << 16
+ if zinfo.filename[-1] == '/':
+ zinfo.external_attr = 0o40775 << 16 # drwxrwxr-x
+ zinfo.external_attr |= 0x10 # MS-DOS directory flag
+ else:
+ zinfo.external_attr = 0o600 << 16 # ?rw-------
else:
zinfo = zinfo_or_arcname