X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=bin%2Funzip.py;h=ab62d240cf83482892dbcd08a0437cf1aa997fb0;hb=f2e9bb3e4991fafccdf54035fb74ce7b2623c607;hp=57af7b1d5a277eec95eb5b9e1e6265c57c98750d;hpb=e534b1760f06109ca7b51a18fc1209f758b32415;p=dotfiles.git diff --git a/bin/unzip.py b/bin/unzip.py index 57af7b1..ab62d24 100755 --- a/bin/unzip.py +++ b/bin/unzip.py @@ -42,10 +42,15 @@ for zinfo in zf.infolist(): if not tgt.endswith('/'): infile = zf.open(zinfo.filename) - fp = open(tgt, 'wb') - copyfileobj(infile, fp) - fp.close() + if zinfo.external_attr == 0xA1ED0000: + os.symlink(infile.read(), tgt) + else: # regular file + fp = open(tgt, 'wb') + copyfileobj(infile, fp) + fp.close() infile.close() - dt = time.mktime(zinfo.date_time + (0, 0, -1)) - os.utime(tgt, (dt, dt)) + if zinfo.external_attr != 0xA1ED0000: + # set timestamp for directories and files but not symlinks + dt = time.mktime(zinfo.date_time + (0, 0, -1)) + os.utime(tgt, (dt, dt)) zf.close()