mysterywolf / minizip

zip manipulation library | zip压缩解压库
12 stars 2 forks source link

解决解压多文件zip报错问题 #3

Closed WCX1024979076 closed 1 year ago

WCX1024979076 commented 1 year ago

之前的代码在测试miniunz解压具有多个文件的zip时报错,报错命令为miniunz -x target.zip,报错内容为error -1 with zipfile in unzGoToNextFile,完整运行日志如下所示,测试平台为bsp/qemu-virt64-aarch64

msh />echo test a.txt
msh />echo test b.txt
msh />minizip -o -9 target.zip a.txt b.txt
MiniZip 1.01b, demo of zLib + Zip package written by Gilles Vollant
more info at http://www.winimage.com/zLibDll/minizip.html

creating target.zip
msh />rm a.txt b.txt
msh />miniunz -x target.zip
MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant
more info at http://www.winimage.com/zLibDll/minizip.html

target.zip opened
 extracting: a.txt
error -1 with zipfile in unzGoToNextFile

经过调试后发现在解压多个文件时存在利用unzClose提前关闭文件的情形,个人更正并且测试通过,测试如下。

msh />ls
Directory /:
target.zip          206                      
msh />miniunz -l target.zip
MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant
more info at http://www.winimage.com/zLibDll/minizip.html

target.zip opened
 Length  Method   Size  Ratio   Date    Time   CRC-32     Name
 ------  ------   ----  -----   ----    ----   ------     ----
      4  Defl:X       6 150%  01-00-80  00:00  d87f7e0c   a.txt
      4  Defl:X       6 150%  01-00-80  00:00  d87f7e0c   b.txt
msh />
msh />miniunz -x target.zip 
MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant
more info at http://www.winimage.com/zLibDll/minizip.html

target.zip opened
 extracting: a.txt
 extracting: b.txt