Skip gzip standard header on decompression

Sep 16, 2009 at 1:17 PM

Hello.

There is a python script which allows extract information from some particular game files. Those files have blocks of data encoded with some algorithm and then compressed with zip.

Now I'm trying to translate that script into C# and I have problem with zlib decompression part. If you see the script on line 237 you'll see that the block size for extraction is negative. According to Python documentation it's undocumented mode that force the zlib decompressor to skip standard gzip header verification on read.

So my question is - how can I do the same with DotNetZip library? Cause when I try to decompress exactly the same data I got "Bad state (unknown compression method (0xDE))" exception (and I verified that I got identical data right before decompression step in both my version and python script version).

Coordinator
Sep 16, 2009 at 3:29 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Sep 16, 2009 at 3:30 PM

Can you give me a .gz file that requires this?  (Upload it to the workitem)

Sep 16, 2009 at 5:31 PM

M... I can either give you full code (it's very short cause it's my test project) and source file. Or I can give you the encrypted block only. What would be more convient for you?

PS: I can upload the file only tomorrow when I'll be on work.

Coordinator
Sep 16, 2009 at 10:26 PM

full code?   not sure what that code would do.

What I would like is the .gz file that omits the GZIP header.  I want to be able to verify that the Ionic.Zlib.GZipStream can read the file.

 

Sep 17, 2009 at 7:26 AM
Edited Sep 17, 2009 at 7:29 AM

Ok, it's here: test.zip

The content of that archive:

  • test.bin - source binary block of data
  • test.py - Python script that can unpack test.bin into python_test.dat file (to run it simply install Python 2.6 and run test.py from command line)
  • python_test.dat - unpacked (by Python zlib) test.bin, you can see it contains a collection of structures with utf32 text data in them

What I'm trying to achieve is that this C# code:

 

File.WriteAllBytes (@"c#_test.dat", ZlibStream.UncompressBuffer (File.ReadAllBytes (@"test.bin")));

 

Could get me the same data as Python version. Now it's only gives me "Ionic.Zlib.ZlibException: Bad state (unknown compression method (0xA4))"

Coordinator
Sep 18, 2009 at 8:06 PM

I'll have a look.

Coordinator
Sep 19, 2009 at 1:10 AM

That file is a bare DEFLATE stream.  What you want is DeflateStream.UncompressBuffer().  I just added that method into v1.9.0.8. 

 

Sep 19, 2009 at 9:13 AM

Oh! Thank you very much!