On Sunday, March 18, 2012 10:05 AM, László Marák wrote:
I would like to ask You what is the status of Boost.zlib on Windows. I have a program that uses Boost.iostreams to create a gzip file. It compiles both on Windows and Linux and on Linux it creates a functional gz file. On Windows it creates a gz file but when I try to decompress the file it gives me "data error".
When I look at Boost's regression tests both gzip and zlib is missing on Windows. Has anybody successfully run Boost.zlib on Windows recently? Is there some flush method that should be called, but on Linux it does not show any symptoms?
I agree with Artyom Beilis. It sounds like you're opening the files in text mode. This causes Windows to insert a carriage return (0x0D) before each line feed (0x0A), but has no effect on Linux or other Unix-like operating systems.
Here is the actual code I use to open a gz or bz2 file for writing in one of my projects, which produced valid gz files with boost 1.48 (untested with 1.49) and Visual Studio 2010, both in i386 and AMD64 modes. Ignore the references to tbb::scalable_allocator. In particular, note the last line where I specify the file_sink should be binary:
boost::iostreams::filtering_stream