Zipfile - zinfo.extra

Tim Howarth tim at worthy.demon.co.uk
Sat Feb 2 06:15:50 EST 2002


I've been trying to write Acorn/RISC OS format zip files using the
Python zipfile module.

Filetype information is not stored as an extension but hidden under
normal filesystems and written in the zipinfo's "extra" field in zip
archives.


I've succeeded in creating correctly formatted zips but only by adding
"extra" as an optional parameter to the zipfile.py module's zipfile
class write method.

def write(self, filename, arcname=None, compress_type=None, extra=None)


Anyone know of a better way to do this ?


AFAICT there are the writestr and write methods.

writestr allows writing of a string (which could be anything) and gives
control over the "info" data - but involves more "fiddling" than
"write" as you have to create all (mandatory) zinfo yourself.

write allows simple "copying" of a file into a zip.


What I'd like to do is write then set zinfo.extra to the filetype data.

-- 
___
 |im    ---- ARM Powered ----



More information about the Python-list mailing list