Date & time in a Zip File

Scott David Daniels Scott.Daniels at Acm.Org
Wed Jul 13 20:32:53 EDT 2005


Tim Williams (gmail) wrote:
> Using zipfile.Zipfile
> 
> How can I add a file to a zip file and keep its date and time correct?
>  Currently the date/time change to the time the file was added to the
> zip.    Zipinfo doesn't have a write method!
> 
> Solutions other than zipfile are welcome, with snippets if possible :)
> 

I am working some new code for zipfile.  If you are interested in a
partial step towards what you want, at the cost of having to read
and/or use a bunch of half-done code, grab a copy of:

	http://members.dsl-only.net/~daniels/zipf.py

You should then be able to do something like:

     import zipf
     z = zipf.ZipFile('whatever.zip', 'a')

and then copy the code for .write(...)
using your own zinfo block.  I imagine I'll eventually have a method
like that named ".write_info(zinfo, data_iterator)" or something.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list