我试图通过调用inflate函数来解压缩文件,但是即使我使用网站上的示例程序,它总是会失败Z_DATA_ERROR.我想也许我的zip文件可能不受支持.我附上了下面的拉链头图片.

这是我为执行解压缩而编写的函数.我立刻读了整个文件(大约34KB)并将其传递给这个函数.注意我已经尝试使用zip标头传递整个zip文件以及跳过zip文件头,并且只有在调用inflate()时,传递压缩数据才会失败,并且Z_DATA_ERROR失败.
int CHttpDownloader::unzip(unsigned char * pDest, unsigned long * ulDestLen, unsigned char * pSource, int iSourceLen)
{
int ret = 0;
unsigned int uiUncompressedBytes = 0; // Number of uncompressed bytes returned from inflate() function
unsigned char * pPositionDestBuffer = pDest; // Current position in dest buffer
unsigned char * pLastSource = &pSource[iSourceLen]; // Last position in source buffer
z_stream strm;
// Skip over local file header
SLocalFileHeader * header = (SLocalFileHeader *) pSource;
pSource += sizeof(SLocalFileHeader) + header->sFileNameLen …Run Code Online (Sandbox Code Playgroud)