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.