how can I put a 1Gb file in a zipfile??

Jeff Epler jepler at unpythonic.net
Sun Mar 20 15:17:20 EST 2005


The limits of ZIP files according to the folks who make info-zip:
http://www.info-zip.org/pub/infozip/FAQ.html#limits

 statistic                             limit
number of files                        65,536
uncompressed size of a single file       4 GB
compressed size of a single file         4 GB
total size of archive                  256 TB
maximum path/filename length            64 KB 

I had no trouble creating a zip file from a 4GB file filled with '\0'
bytes:
$ python bennie.py
$ ls -ls test.zip big
  12 -rw-rw-r--  1 jepler jepler 4294967296 Mar 20 14:11 big
4084 -rw-rw-r--  1 jepler jepler    4174545 Mar 20 14:14 test.zip

I'm using Python 2.3.3 on Fedora Core 2.
#------------------------------------------------------------------------
# bennie.py
def make_4gb_file(f):
    f = open(f, "w")
    f.seek ( 4 * 1024 * 1024 * 1024 - 1)
    f.write("\0")
    f.close()

import zipfile
z = zipfile.ZipFile("/tmp/test.zip", "w", zipfile.ZIP_DEFLATED)
make_4gb_file("/tmp/big")
z.write("/tmp/big")
z.close()
#------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050320/b2f7467c/attachment.sig>


More information about the Python-list mailing list