|
Boost Users : |
Subject: [Boost-users] [iostreams] gzip filter produces files with trailing garbage
From: Michael Harris (michael.harris_at_[hidden])
Date: 2009-07-22 22:12:33
Hi,
I am using boost::iostreams in a project that I am currently working on.
The relevant part of my code is shown below:
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
...
void FileDataStore::write(DataSet *ds) {
filtering_ostream os;
// Check if we are writing a gzipped file
int iext = this->filename.find_last_of('.');
if (iext != std::string::npos && this->filename.substr(iext+1)
== "gz") {
os.push(gzip_compressor());
}
try {
os.push(file_descriptor_sink(this->filename));
} catch (std::ios_base::failure e) {
throw IOException() << errmsg_info((boost::format("Error
opening file '%s': %s") % this->filename %
strerror(errno)).str().c_str());
}
// Write my stuff to os
os.flush();
os.pop();
}
Basically, if the filename being used ends in .gz I want the file
written through a gzip filter so it is stored gzipped.
The problem is: if I unzip the resulting file using gzip I get a message
like this:
gzip: myfile.gz: decompression OK, trailing garbage ignored
The file content is OK but this message is annoying.
What am I doing wrong that causes this?
Many thanks,
Regards // Mike
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