ZipFile and file rigths
perchef
francois.perche at gmail.com
Sun Jul 10 06:10:48 EDT 2005
hi,
i have written this small code which allow me to unzip files using
python :
import zipfile
import os
import os.path
pathDir="/home/toto/Desktop"
pathZip= os.path.join(pathDir,"foobar.zip")
if zipfile.is_zipfile(pathZip):
zf = zipfile.ZipFile(pathZip)
for file in zf.namelist():
newPath = os.path.join(pathDir,file)
print newPath
if not file.endswith('/') and not os.path.exists(newPath) :
newFile = open(newPath, 'wb')
newFile.write(zf.read(file))
newFile.flush()
newFile.close()
else :
os.makedirs(newPath)
zf.close()
else:
print pathZip + " is not a zip file"
it works well but i have a small problem : i can't see how i can deal
with file rights.
When I unzip files with this script all the unzipped files haven't the
good rights.
for example :
with this script :
-rw-r--r-- foo.exe
with a traditional zip program (ie : stuffit ):
-rwxr-xr-x foo.exe
ZipInfo objects doesn't store informations about rights ?
(http://www.python.org/doc/current/lib/zipinfo-objects.html#zipinfo-objects)
How can i fix this ?
More information about the Python-list
mailing list