Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions include/seqan3/io/sequence_file/output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,31 @@ class sequence_file_output
/*!\brief Construct from filename.
* \param[in] filename Path to the file you wish to open.
* \param[in] fields_tag A seqan3::fields tag. [optional]
* \param[in] openmode The open mode for the file stream. [optional]
*
* \details
*
* In addition to the file name, you may specify a custom seqan3::fields type which may be easier than
* defining all the template parameters.
*
* You may also specify the open mode for the file stream. `std::ios_base::out` and `std::ios::binary` will always
* be added regardless of the given open mode.
* `std::ios_base::app` can be used to open the file in append mode.
*
* ### Compression
*
* This constructor transparently applies a compression stream on top of the file stream in case
* the given file extension suggests the user wants this.
* See the section on \link io_compression compression and decompression \endlink for more information.
*/
sequence_file_output(std::filesystem::path filename,
selected_field_ids const & SEQAN3_DOXYGEN_ONLY(fields_tag) = selected_field_ids{}) :
selected_field_ids const & SEQAN3_DOXYGEN_ONLY(fields_tag) = selected_field_ids{},
std::ios_base::openmode openmode = std::ios_base::out | std::ios::binary) :
primary_stream{new std::ofstream{}, stream_deleter_default}
{
primary_stream->rdbuf()->pubsetbuf(stream_buffer.data(), stream_buffer.size());
static_cast<std::basic_ofstream<char> *>(primary_stream.get())
->open(filename, std::ios_base::out | std::ios::binary);
->open(filename, openmode | std::ios_base::out | std::ios::binary);

if (!primary_stream->good())
throw file_open_error{"Could not open file " + filename.string() + " for writing."};
Expand Down
Loading