提高:: iostream的zlib的COM pressing多个文件合并成一个档案 [英] boost::iostream zlib compressing multiple files into one archive

查看:310
本文介绍了提高:: iostream的zlib的COM pressing多个文件合并成一个档案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法打包一堆文件到一个存档。升压文档都在这个话题非常有限,我搜索了几个小时的网,现在,但我不能找到一个解决方案。

i'm having trouble packing a bunch of files into one archive. the boost docs are very limited on this topic and i've searched the web for several hours now, but i can't find a solution.

是我到目前为止有:

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){...}

我如何添加文件到zip归档?显然提供的方法是不行的,我只是不能在文档或头文件的主题找到任何

how do i add the files to the zip archive? the method provided obviously doesn't work, i just can't find anything on the subject in the docs or header files

推荐答案

zlib的未实现ZIP文件格式,它只是实现邮编内使用的流COM pression(见的 zlib的常见问题解答)。据我所知,(我要警告你,绝不是全部),升压不包括功能来读取或写入Zip文件。还有那些提供该功能库当然,例如,的ZZipLib (注:该站点下来的那一刻)。

zlib does not implement the Zip file format, it just implements the stream compression used within Zip (see the zlib FAQ). To my knowledge (which I should warn you is by no means total), Boost does not include functionality to read or write Zip archives. There are libraries that do provide that functionality of course, for example, zziplib (note: the site appears to be down at the moment).

编辑:很显然,实际的ZZipLib 不能的写Zip文件,它只能读取。不过,我敢肯定一点谷歌搜索会变成了可写格式的库。

Apparently, zziplib actually can't write Zip files, it can only read them. Still, I'm sure a little googling would turn up a library capable of writing the format.

这篇关于提高:: iostream的zlib的COM pressing多个文件合并成一个档案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆