Reading online zip files - zipfile and zlib, wbits

Discussion in 'Python' started by Brendan, Dec 12, 2008.

  1. Brendan

    Brendan Guest

    I am fooling around with accessing contents of zip files online. I
    download the tail end of the zip and use zipfile to get the zip
    central directory structure. I download the section of the zip file I
    need, directly read the zip file headers and use that information with
    zlib to uncompress the data. The files I am examining will always be
    compressed using deflate, with a wbits value of -15(minus for
    headerless data because I am unsure whether the zip file header is
    what zlib expects).

    I can not find anywhere in the PK Zip Application notes (
    http://www.pkware.com/documents/casestudies/APPNOTE.TXT ) how to
    determine the value I should uze for wbits with zlib.decompress. I
    have determined it is -15 from experimentation. Does anyone know the
    answer to this?
     
    Brendan, Dec 12, 2008
    #1
    1. Advertising

  2. Brendan

    Brendan Guest

    On Dec 12, 10:25 am, Brendan <> wrote:
    > I am fooling around with accessing contents of zip files online. I
    > download the tail end of the zip and use zipfile to get the zip
    > central directory structure. I download the section of the zip file I
    > need, directly read the zip file headers and use that information with
    > zlib to uncompress the data. The files I am examining will always be
    > compressed using deflate, with a wbits value of -15(minus for
    > headerless data because I am unsure whether the zip file header is
    > what zlib expects).
    >
    > I can not find anywhere in the PK Zip Application notes (http://www.pkware.com/documents/casestudies/APPNOTE.TXT) how to
    > determine the value I should uze for wbits with zlib.decompress. I
    > have determined it is -15 from experimentation. Does anyone know the
    > answer to this?


    Okay, I found part of the answer here in the zip app notes
    Now I just don't understand Why Normal deflate corresponds to 15
    wbits, and why I have to use headerless for the data, i.e. wbits = -15.
     
    Brendan, Dec 12, 2008
    #2
    1. Advertising

  3. Brendan

    Brendan Guest

    On Dec 12, 10:46 am, Brendan <> wrote:
    > On Dec 12, 10:25 am, Brendan <> wrote:
    >
    > > I am fooling around with accessing contents of zip files online. I
    > > download the tail end of the zip and use zipfile to get the zip
    > > central directory structure. I download the section of the zip file I
    > > need, directly read the zip file headers and use that information with
    > > zlib to uncompress the data. The files I am examining will always be
    > > compressed using deflate, with a wbits value of -15(minus for
    > > headerless data because I am unsure whether the zip file header is
    > > what zlib expects).

    >
    > > I can not find anywhere in the PK Zip Application notes (http://www.pkware.com/documents/casestudies/APPNOTE.TXT) how to
    > > determine the value I should uze for wbits with zlib.decompress. I
    > > have determined it is -15 from experimentation. Does anyone know the
    > > answer to this?

    >
    > Okay, I found part of the answer here in the zip app notes
    >
    >
    > Now I just don't understand Why Normal deflate corresponds to 15
    > wbits, and why I have to use headerless for the data, i.e. wbits = -15.


    Seems the bit flags are not properly set, bit 2 should be 0 and bit 1
    should be 1, to correspond to maximum compression i.e. wbit = 15.
    Still don't know why wbits has to be negative.
     
    Brendan, Dec 12, 2008
    #3
  4. Brendan

    Brendan Guest

    On Dec 12, 11:36 am, Brendan <> wrote:
    > On Dec 12, 10:46 am, Brendan <> wrote:
    >
    >
    >
    >
    >
    > > On Dec 12, 10:25 am, Brendan <> wrote:

    >
    > > > I am fooling around with accessing contents of zip files online. I
    > > > download the tail end of the zip and use zipfile to get the zip
    > > > central directory structure. I download the section of the zip file I
    > > > need, directly read the zip file headers and use that information with
    > > > zlib to uncompress the data. The files I am examining will always be
    > > > compressed using deflate, with a wbits value of -15(minus for
    > > > headerless data because I am unsure whether the zip file header is
    > > > what zlib expects).

    >
    > > > I can not find anywhere in the PK Zip Application notes (http://www.pkware.com/documents/casestudies/APPNOTE.TXT) how to
    > > > determine the value I should uze for wbits with zlib.decompress. I
    > > > have determined it is -15 from experimentation. Does anyone know the
    > > > answer to this?

    >
    > > Okay, I found part of the answer here in the zip app notes
    > >

    >
    > > Now I just don't understand Why Normal deflate corresponds to 15
    > > wbits, and why I have to use headerless for the data, i.e. wbits = -15.

    >
    > Seems the bit flags are not properly set, bit 2 should be 0 and bit 1
    > should be 1, to correspond to maximum compression i.e. wbit = 15.
    > Still don't know why wbits has to be negative.- Hide quoted text -
    >
    > - Show quoted text -


    Arg! Tried a different tack. Took the file header plus compressed
    file and concatenated with central directory. Now need only zipfile
    module.
     
    Brendan, Dec 12, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alan Toppen

    zlib and zipfile module in Python2.4

    Alan Toppen, Apr 11, 2005, in forum: Python
    Replies:
    3
    Views:
    757
    Fredrik Lundh
    Apr 12, 2005
  2. Jan Prochazka

    zlib and zip files

    Jan Prochazka, Apr 14, 2006, in forum: Python
    Replies:
    0
    Views:
    271
    Jan Prochazka
    Apr 14, 2006
  3. Márcio Faustino
    Replies:
    3
    Views:
    343
    Márcio Faustino
    Apr 12, 2009
  4. Graham Wood
    Replies:
    3
    Views:
    546
    A. Sinan Unur
    Jan 11, 2004
  5. Twig
    Replies:
    1
    Views:
    130
    A. Sinan Unur
    Jan 27, 2006
Loading...

Share This Page