diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-09-23 22:42:02 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-09-23 22:42:02 +0300 |
commit | 385ffbffe6f129411811ce33156058c0aa183eac (patch) | |
tree | 54714ea4767bd84b6621ef8330718ff274315eb3 /Lib/zipfile.py | |
parent | 09a555eb381b88fbb0985bee573b0458e353f8d3 (diff) | |
parent | 46a34924e45d7a0a4d0e31bdc54eef30c0afa44e (diff) | |
download | cpython-git-385ffbffe6f129411811ce33156058c0aa183eac.tar.gz |
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.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py index e5b7818635..7e07f11d79 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 |