ZLib Inflate() failing with -3 Z_DATA_ERROR

六月ゝ 毕业季﹏ 提交于 2019-12-01 16:59:10

Inflate() was failing because it was looking for GZip headers which were not present. If you initialize the stream with:

ret = inflateInit2(&strm, -MAX_WBITS);

Passing a negative window bits value prevents inflate from checking for gzip or zlib headers and unzipping works as expected.

That file that begins with 50 4B 03 04 is a zip file. The zlib library does not process zip files directly. zlib can help with the compression, decompression, and crc calculations. However you need other code to process the zip file format.

You can look at contrib/minizip in the zlib distribution, or libzip.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!