I am trying to decompress a .gz file that comes from a material board with custom headers using python.
I have as example a C++ file that decompress that file using the inflateInit2 function from the zlib the following way :
inflateInit2(&stream,MAX_WBITS + 16);
where stream is a z_stream. My usage of the lib in python is as follow :
f = open("../myfile.gz", "rb").read()
zlib.decompress(f, zlib.MAX_WBITS)
where I change the second parameter of the decompress function trying several possibilities, because the python library does not include the inflateInit2 methode.
I've found this topic that gives various example of usage of the lib, but none of them work (or the C++ calculus of W_BITS) in my case and always generate one of these error :
invalid block typeincomplete or truncated streaminconsistent stream state
The C++ code seems to be deleting the generic .gz header to use a custom one because the compression algorithm contain this line that is then prepend to the data.
uint8_t headerGz[] = {0x1F, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00};
So my guess is that these header does not match the usual ones and that is why either gunzip or libz cannot decompress the file. Maybe also the z_stream way of doing treat the file in a different way.
Am I missing something ? Many thanks ! Kev'