Troy Potts <troy.po...@gmail.com> added the comment:

I have attempted to implement a ZipFile.remove function.  It seems to work 
fine.  I have submitted a patch.

The method of implementation is: find the file's index in the file list, then 
sum the lengths of the file entries before it to find its location in the 
archive.  Then simply read in all the bytes after it, write them out at that 
location, and truncate the file x bytes shorter, where x is the length of the 
record.  This works because the directory listing is created when the file is 
closed, so there's no harm in truncating.

I've also made it truncate the zip file after reading in the existing files 
upon creation, because the directory information is not used after this point.

This could use some testing on large files.

This is my first patch, so let me know if I've done anything wrong.

----------
keywords: +patch
nosy: +chroipahtz
Added file: http://bugs.python.org/file17847/zipfile_remove.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue6818>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to