From f791529c999c42b126b2e7a7cb8265028defb0d9 Mon Sep 17 00:00:00 2001 From: Gabriel Studer <gabriel.studer@unibas.ch> Date: Tue, 2 Jan 2024 14:08:36 +0100 Subject: [PATCH] mmcif writer: automatically apply gzip compression when file ends with ".gz" --- modules/io/src/mol/star_writer.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/io/src/mol/star_writer.cc b/modules/io/src/mol/star_writer.cc index 1a017e934..b06270bb8 100644 --- a/modules/io/src/mol/star_writer.cc +++ b/modules/io/src/mol/star_writer.cc @@ -17,6 +17,10 @@ // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA //------------------------------------------------------------------------------ +#include <boost/iostreams/filter/gzip.hpp> +#include <boost/algorithm/string/predicate.hpp> +#include <boost/filesystem.hpp> + #include <ost/io/mol/star_writer.hh> namespace ost{ namespace io{ @@ -40,6 +44,9 @@ StarWriter::StarWriter(const String& filename): filename_(filename), << strerror(errno) << std::endl; throw IOException(ss.str()); } + if (boost::iequals(".gz", boost::filesystem::extension(filename))) { + stream_.push(boost::iostreams::gzip_compressor()); + } stream_.push(fstream_); } -- GitLab