gpt4 book ai didi

c++ - 解压缩二进制文件时错误的 EOF

转载 作者:行者123 更新时间:2023-11-28 08:30:03 29 4
gpt4 key购买 nike

我尝试使用 Lucian Wischik 的 Zip Utils 将二进制文件从 zip 存档解压缩到 membuf:

http://www.wischik.com/lu/programmer/zip_utils.html

http://www.codeproject.com/KB/files/zip_utils.aspx

FindZipItem(hz, filename.c_str(), true, &j, &ze);
char *content = new char[ze.unc_size];
UnzipItem(hz, j, content, ze.unc_size);
delete[] content;

但它没有正确解压缩文件。它在文件的第一个 0x00 处停止。

例如,当我在 ZIP 压缩文件中解压一个 MP3 文件时,它只会解压前 4 个字节:0x49443303 (ID3\0) 因为第 5 到第 8 个字节是 0x00.

我还 try catch ZR_RESULT,它总是返回 ZR_OK(这意味着已完成且没有错误)。

我想这个人也有同样的问题,但是没有人回答他的问题:

http://www.codeproject.com/KB/files/zip_utils.aspx?msg=2876222#xx2876222xx

任何形式的帮助将不胜感激:)

最佳答案

它可能解压得很好。请记住,许多面向字符串的显示 函数将在第一个'\0' 处停止输出字符。甚至您的调试器也会在您的监 window 口中显示一个 char* ,就好像它是一个字符串一样。它只能猜测字符数组中的数据是什么...您如何测试解压缩了多少字节?

你可能想尝试这样的事情:

FindZipItem(hz, filename.c_str(), true, &j, &ze);
char *content = new char[ze.unc_size];
memset(content, 0, ze.unc_size); // added so we can say that if it has a bunch of 0 bytes, then the unzip stopped early.
UnzipItem(hz, j, content, ze.unc_size);

// will print in hex all of the bytes in the array
for(int i = 0; i < ze.unc_size; ++i) {
printf("%02x ", content[i]);
}

delete[] content;

关于c++ - 解压缩二进制文件时错误的 EOF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2551877/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com