|
Boost Users : |
Subject: Re: [Boost-users] concat files for compression
From: Kraus Philipp (philipp.kraus_at_[hidden])
Date: 2010-06-15 14:10:38
Am 15.06.2010 um 18:54 schrieb Steven Watanabe:
> AMDG
>
> Kraus Philipp wrote:
>> Thanks that was a very big hint.
>>
>> My code is now:
>>
>> bio::basic_null_sink<char> l_out;
>> bio::counter l_counter;
>> bio::filtering_streambuf< bio::output > l_deflate;
>>
>> l_deflate.push( bio::gzip_compressor() );
>> l_deflate.push( boost::ref(l_counter) );
>> l_deflate.push( l_out );
>>
>> std::ifstream l_file( p_str1.c_str(), std::ifstream::in |
>> std::ifstream::binary );
>> bio::copy( l_file, l_deflate );
>> l_file.close();
>>
>> l_file.open( p_str2.c_str(), std::ifstream::in |
>> std::ifstream::binary );
>> ===> bio::copy( l_file, l_deflate ); <==== error
>> l_file.close();
>>
>> It works perfectly, except the second copy. On this line I get a
>> "segmentation fault" (sorry I can't use the debugger, because the
>> code runs on another system).
>
> I'm guessing that the problem is that copy closes the sink.
Yes: http://boost.sourceforge.net/libs/iostreams/doc/functions/copy.html
The function template copy reads data from a given model of Source and
writes it to a given model of Sink until the end of stream is reached.
It then closes both components, using the function template close, and
returns the number of characters written.
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