diff options
author | Stuart Rackham <srackham@methods.co.nz> | 2011-02-07 18:26:45 +1300 |
---|---|---|
committer | Stuart Rackham <srackham@methods.co.nz> | 2011-02-07 18:26:45 +1300 |
commit | 82325eeb449498f6f71806fd633636cb5b4620d3 (patch) | |
tree | 73f8a88352e9ab504a28e19760ef709ead837880 | |
parent | 0bc4095b53ae6a3c150c3262fe44c74301d2241a (diff) | |
download | asciidoc-82325eeb449498f6f71806fd633636cb5b4620d3.tar.gz |
FIXED: --filter install command restores archived file permissions correctly.
-rwxr-xr-x | asciidoc.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/asciidoc.py b/asciidoc.py index 0b69bf4..d3c9dfb 100755 --- a/asciidoc.py +++ b/asciidoc.py @@ -5360,15 +5360,18 @@ def unzip(zip_file, destdir): """ zipo = zipfile.ZipFile(zip_file, 'r') try: - for name in zipo.namelist(): - if not name.endswith('/'): - d, fname = os.path.split(name) + for zi in zipo.infolist(): + outfile = zi.filename + if not outfile.endswith('/'): + d, outfile = os.path.split(outfile) directory = os.path.normpath(os.path.join(destdir, d)) if not os.path.isdir(directory): os.makedirs(directory) - fname = os.path.join(directory, fname) - message.verbose('extracting: %s' % fname) - file(fname, 'wb').write(zipo.read(name)) + outfile = os.path.join(directory, outfile) + perms = (zi.external_attr >> 16L) & 0777 + message.verbose('extracting: %s' % outfile) + fh = os.open(outfile, os.O_CREAT | os.O_WRONLY, perms) + os.write(fh, zipo.read(zi.filename)) finally: zipo.close() |