【发布时间】:2021-08-24 01:23:06
【问题描述】:
我在 VS 2019 的 Windows 的 C++ 应用程序中实现了 Poco,使用了这篇文章中的提示:How to use Poco::ZIP to compress/decompress zip file
我已经想出了如何使用此代码 sn-p 递归压缩文件夹:
// Now that we have an output file name, compress
std::ofstream fos(z_file, std::ios::binary);
Poco::Zip::Compress c(fos, true);
Poco::File aFile(file_path);
if (aFile.exists()) {
Poco::Path p(aFile.path());
if (aFile.isDirectory()) {
c.addRecursive(p, Poco::Zip::ZipCommon::CompressionMethod::CM_AUTO,
Poco::Zip::ZipCommon::CL_MAXIMUM, true);
}
}
else {
std::cout << "File not found... \r\n";
}
// Just in case these don't get called above.
c.close(); // MUST be done to finalize the Zip file
fos.close();
return z_file;
}
我的问题是,一旦代码到达,
c.addRecursive(p, Poco::Zip::ZipCommon::CompressionMethod::CM_AUTO,
Poco::Zip::ZipCommon::CL_MAXIMUM, true);
程序继续正常运行,并且压缩文件夹就好了。但是,程序不会返回到正常的执行流程。它会在线程上消失并且不会回来吗?我研究过我可以通过
获取有关添加到存档中的文件的更新Poco::FIFOEvent<const ZipLocalFileHeader> EDone;
它还说关闭文件对于创建存档至关重要,但似乎使用 addRecursive 我的 close() 永远不会被调用。
任何帮助将不胜感激。
问候
【问题讨论】:
标签: c++ directory compression