Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The <a href="http://www.gzip.org/zlib/rfc-gzip.html#header-trailer" rel="noreferrer">gzip format</a> specifies a field called <code>ISIZE</code> that:</p> <blockquote> <p>This contains the size of the original (uncompressed) input data modulo 2^32.</p> </blockquote> <p>In <a href="http://pydoc.org/get.cgi/usr/local/lib/python2.5/gzip.py" rel="noreferrer">gzip.py</a>, which I assume is what you're using for gzip support, there is a method called <code>_read_eof</code> defined as such:</p> <pre><code>def _read_eof(self): # We've read to the end of the file, so we have to rewind in order # to reread the 8 bytes containing the CRC and the file size. # We check the that the computed CRC and size of the # uncompressed data matches the stored values. Note that the size # stored is the true file size mod 2**32. self.fileobj.seek(-8, 1) crc32 = read32(self.fileobj) isize = U32(read32(self.fileobj)) # may exceed 2GB if U32(crc32) != U32(self.crc): raise IOError, "CRC check failed" elif isize != LOWU32(self.size): raise IOError, "Incorrect length of data produced" </code></pre> <p>There you can see that the <code>ISIZE</code> field is being read, but only to to compare it to <code>self.size</code> for error detection. This then should mean that <code>GzipFile.size</code> stores the actual uncompressed size. However, I <em>think</em> it's not exposed publicly, so you might have to hack it in to expose it. Not so sure, sorry.</p> <p>I just looked all of this up right now, and I haven't tried it so I could be wrong. I hope this is of some use to you. Sorry if I misunderstood your question.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload