(C++) Error ZR_FLATE when unzipping a file of 0 bytes. Unzip source: "Zip Utils -clean, elegant...."
I am using unzip.h and .cpp from this source: http://www.codeproject.com/KB/files/zip_utils.aspx
As the title says - when I unzip a file with 0 bytes I get ZR_FALTE. I have searched for this error all over and not found any answer. I have also posted a question on codeproject for the 开发者_开发知识库author codeproject post but the same question have been asked there before without answers.
My question is if anyone have worked with that source before and knows how to fix it. Or during which other conditions the error can occurr.
The current way I narrow the error down and ignore it is:
ZENTRY zEntry;
ZRESULT zRes;
// uncompress...
if (zRes == ZR_FLATE && zEntry.comp_size == 0 && zEntry.unc_size == 0)
{
// No error
}
The definition for the error in the source is: "an internal error in the de/inflation code"
Thanks
This is an error in function: unzReadCurrentFile(...). You can fix it by adding the following lines (in unzip.cpp line:3486):
if(pfile_in_zip_read_info->rest_read_uncompressed==0)
{
if (reached_eof!=0) *reached_eof=true;
return UNZ_EOF;
};
As you can see, the EOF detection is broken for zero-sized files, I guess that's because of buffer size checks, that were added later.
精彩评论