Skip to content

Commit 3d198d3

Browse files
committed
[WIP] append to sequence file output
1 parent ca62168 commit 3d198d3

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

include/seqan3/io/sequence_file/output.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,14 @@ class sequence_file_output
146146
* See the section on \link io_compression compression and decompression \endlink for more information.
147147
*/
148148
sequence_file_output(std::filesystem::path filename,
149-
selected_field_ids const & SEQAN3_DOXYGEN_ONLY(fields_tag) = selected_field_ids{}) :
149+
selected_field_ids const & SEQAN3_DOXYGEN_ONLY(fields_tag) = selected_field_ids{},
150+
sequence_file_output_options output_options = sequence_file_output_options{}) :
151+
options{std::move(output_options)},
150152
primary_stream{new std::ofstream{}, stream_deleter_default}
151153
{
152154
primary_stream->rdbuf()->pubsetbuf(stream_buffer.data(), stream_buffer.size());
153155
static_cast<std::basic_ofstream<char> *>(primary_stream.get())
154-
->open(filename, std::ios_base::out | std::ios::binary);
156+
->open(filename, (options.append ? std::ios_base::app : std::ios_base::out) | std::ios::binary);
155157

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

include/seqan3/io/sequence_file/output_options.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ struct sequence_file_output_options
4040

4141
//!\brief Complete header given for embl or genbank
4242
bool embl_genbank_complete_header = false;
43+
44+
//!\brief Whether to open the file in append mode.
45+
bool append = false;
4346
};
4447

4548
} // namespace seqan3

0 commit comments

Comments
 (0)