我在將一堆文件打包到一個存檔時遇到問題。助推文檔是非常有限的這個話題,我已經搜索了幾個小時的網絡,但我找不到解決方案。boost :: iostream zlib將多個文件壓縮到一個存檔中
是我到目前爲止有:
boost::filesystem::ofstream ofsArchive("some.zip");
boost::iostreams::filtering_ostreambuf outFilter;
boost::iostreams::zlib_params zparam(boost::iostreams::zlib::default_compression);
try
{
// set up the filter
outFilter.strict_sync();
outFilter.push(boost::iostreams::zlib_compressor(zparam));
outFilter.push(ofsArchive);
for(each object of some kind)
{
// create a binary serialized file
boost::filesystem::ofstream ofs(filename, std::ios_base::binary);
boost::archive::binary_oarchive bin_oa(ofs);
bin_oa << crazyObject;
// here's where i'm stuck. how to add multiple files to the "some.zip"?
boost::iostreams::copy(ofs, outputArchive);
}
}
catch(boost::iostreams::zlib_error& e){...}
如何將文件添加到壓縮存檔?提供的方法顯然不起作用,我只是在文檔或頭文件中找不到任何關於此主題的內容