gzip and file size
taw_usenet at yahoo.com
Tue Nov 6 17:28:20 CET 2001
Martin von Loewis <loewis at informatik.hu-berlin.de> wrote in message news:<j4u1w89rig.fsf at informatik.hu-berlin.de>...
> taw_usenet at yahoo.com (ToddW) writes:
> > It's simple to get the correct file size for a file. But if it is
> > gzipped, is there a simple way to snag the file size of the
> > uncompressed file?
> The last four bytes of the file contain the uncompressed size, unless
> the file is corrupted. If the compressed file was created by
> contatenating multiple compressed files, you can obtain the true
> uncompressed size only by uncompressing the entire file.
Hey thanks. As I am using python 1.5.2 this was the answer I needed.
And here's my iittle function for those interested (notice the format
is little endian BTW):
"""return UNCOMPRESSED filesize of a gzipped file.
fo = open(filename, 'rb')
r = fo.read()
return struct.unpack('<I', r)
Thanks for all of your replies. The references to getinfo, etc., applies to
More information about the Python-list