Tôi gặp sự cố khi đóng gói một loạt tệp vào một tệp lưu trữ. tài liệu tăng rất hạn chế về chủ đề này và tôi đã tìm kiếm trên web trong vài giờ, nhưng tôi không thể tìm thấy giải pháp.boost :: iostream zlib nén nhiều tệp vào một kho lưu trữ
gì tôi có cho đến nay:
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){...}
làm thế nào để thêm các tập tin vào kho lưu trữ zip? phương pháp được cung cấp rõ ràng không hoạt động, tôi không thể tìm thấy bất kỳ nội dung nào trong chủ đề trong tài liệu hoặc tệp tiêu đề