47 std::string extension = filename.extension().native();
49 if (extension ==
".gz")
52 filename.replace_extension(
"");
53 return {
new contrib::basic_gz_ostream<char_t>{primary_stream}, stream_deleter_default};
55 throw file_open_error{
"Trying to write a gzipped file, but no ZLIB available."};
58 else if ((extension ==
".bgzf") || (extension ==
".bam"))
61 if (extension !=
".bam")
62 filename.replace_extension(
"");
64 return {
new contrib::basic_bgzf_ostream<char_t>{primary_stream}, stream_deleter_default};
66 throw file_open_error{
"Trying to write a bgzf'ed file, but no ZLIB available."};
69 else if (extension ==
".bz2")
72 filename.replace_extension(
"");
73 return {
new contrib::basic_bz2_ostream<char_t>{primary_stream}, stream_deleter_default};
75 throw file_open_error{
"Trying to write a bzipped file, but no libbz2 available."};
78 else if (extension ==
".zst")
80 throw file_open_error{
"Trying to write a zst'ed file, but SeqAn does not yet support this."};
83 return {&primary_stream, stream_deleter_noop};
auto make_secondary_ostream(std::basic_ostream< char_t > &primary_stream, std::filesystem::path &filename) -> std::unique_ptr< std::basic_ostream< char_t >, std::function< void(std::basic_ostream< char_t > *)> >
Depending on the given filename/extension, create a compression stream or just forward the primary st...
Definition misc_output.hpp:36