diff --git a/include/seqan3/io/sequence_file/output.hpp b/include/seqan3/io/sequence_file/output.hpp index 1b07e5ccd6..dce4a2aecd 100644 --- a/include/seqan3/io/sequence_file/output.hpp +++ b/include/seqan3/io/sequence_file/output.hpp @@ -133,12 +133,17 @@ 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 @@ -146,12 +151,13 @@ class sequence_file_output * 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 *>(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."};