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.> > Regards,> Martin
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):
def gzipFileSize(filename):
"""return UNCOMPRESSED filesize of a gzipped file.
"""
fo = open(filename, 'rb')
fo.seek(-4, 2)
r = fo.read()
fo.close()
return struct.unpack('<I', r)[0]
Thanks for all of your replies. The references to getinfo, etc., applies to
python 2+.