alex-zhang / alex-zhang.github.io Goto Github PK
View Code? Open in Web Editor NEWblog
blog
有的时候需要在mac或linux的server生成一写window用的zip资源,但是
https://msdn.microsoft.com/en-us/library/windows/desktop/gg258117(v=vs.85).aspx
··· python
#!/usr/bin/python
import sys
import os
import zipfile
import shutil
inputZipPath = os.path.normpath(str(sys.argv[1]))
print 'inputZipPath', inputZipPath
print '-----------------------------------'
inputZipDirPath = os.path.dirname(inputZipPath)
inputZipBasename = os.path.basename(inputZipPath)
inputTempZipPath = os.path.join(inputZipDirPath, '__' + inputZipBasename)
shutil.copyfile(inputZipPath, inputTempZipPath)
print 'copy temp file to', inputTempZipPath
with zipfile.ZipFile(inputTempZipPath, 'r', zipfile.ZIP_DEFLATED) as inputTargetZip:
with zipfile.ZipFile(inputZipPath, 'w', zipfile.ZIP_DEFLATED) as outputTargetZip:
for inputfileinfo in inputTargetZip.infolist():
inputfilename = inputfileinfo.filename
inputfileIsDir = inputfilename.endswith('/')
inputfilenameDepth = len(inputfilename.split('/'))
if inputfileIsDir: inputfilenameDepth -= 1
inputfilebasename = os.path.basename(inputfilename)
inputfilepurename = os.path.splitext(inputfilebasename)[0]
inputfileextname = os.path.splitext(inputfilebasename)[1]
# print inputfilename
# print inputfilenameDepth
#we make the fake create_system
inputfileinfo.create_system = 0
if inputfilenameDepth == 2:
if(inputfileIsDir or
(inputfileextname != '.exe' and
inputfileextname != '.pdf')):
# http://stackoverflow.com/questions/434641/how-do-i-set-permissions-attributes-on-a-file-in-a-zip-file-using-pythons-zip/6297838#6297838
# http://unix.stackexchange.com/questions/14705/the-zip-formats-external-file-attribute
# https://msdn.microsoft.com/en-us/library/windows/desktop/gg258117(v=vs.85).aspx
print inputfilename
print hex(inputfileinfo.external_attr)
#inputfileinfo.external_attr = inputfileinfo.external_attr | 0x2
#print inputfileinfo.create_system
if(inputfileIsDir):
inputfileinfo.external_attr = 0x12
else:
inputfileinfo.external_attr = 0x2
print 'change to'
print hex(inputfileinfo.external_attr)
outputTargetZip.writestr(inputfileinfo, inputTargetZip.read(inputfilename))
os.remove(inputTempZipPath)
···
今天和同事在聊web dom的事情,听他说web
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.