|
Boost Users : |
Subject: Re: [Boost-users] concat files for compression
From: Roland Bock (rbock_at_[hidden])
Date: 2010-06-13 09:41:21
Philipp Kraus wrote:
> On 2010-06-11 09:34:27 +0200, Roland Bock said:
>
>> Kraus Philipp wrote:
>>> Hi,
>>>
>>> on my previous posting I have another questing:
>>>
>>> I create my compression stream with
>>>
>>> bio::filtering_streambuf< bio::input > l_deflate;
>>> switch (m_compress) {
>>> case gzip : l_deflate.push( bio::gzip_compressor() );
>>> break;
>>> case bzip2 : l_deflate.push( bio::bzip2_compressor() );
>>> break;
>>> }
>>>
>>> For a single file I push it to zip with:
>>>
>>> l_deflate.push( bio::file_source(p_str1, BOOST_IOS::binary) );
>>>
>>> I need a concatination for two files like:
>>> l_deflate.push( bio::file_source(p_str1, BOOST_IOS::binary) );
>>> l_deflate.push( bio::file_source(p_str2, BOOST_IOS::binary) );
>>>
>>> for unix shell I do this with:
>>>
>>> cat file1.txt > tozip.txt
>>> cat file2.txt >> tozip.txt
>>>
>>> How I can push a concatinated file to the deflate stream buffer?
>>>
>>> Thanks
>>>
>>> Phil
>>
>> Hi,
>>
>> I see two options:
>>
>> a) You write a new multi_file_source class which can any number of input
>> files.
>>
>> b) Instead of working with a source, you could work with a sink at the
>> other end of the pipeline. Then just copy the content of the two files
>> into the stream.
>
> Hi,
>
> I think I would like to use the second idea, but how I can do this?
>
> Thx
>
> Phil
Hi,
currently, all your examples are using filtering input streams with a
source. For concatination and compression I would use a filtering output
stream and a sink (for instance a file sink).
Then you open an ifstream for the first file and copy its content into
the filtering output stream.
Then you open an ifstream for the second file and copy its content into
the filtering output stream.
HTH
Regards,
Roland
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net