Skip to content

Commit

Permalink
If available, use std::ios::noreplace when opening files for writing
Browse files Browse the repository at this point in the history
  • Loading branch information
robomics committed Nov 11, 2024
1 parent a3fa4ef commit 4865938
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/nchg/compute/compute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ static void write_chrom_sizes_to_file(const hictk::Reference &chroms,

std::ofstream fs{};
fs.exceptions(fs.exceptions() | std::ios::badbit | std::ios::failbit);
#ifdef __cpp_lib_ios_noreplace
fs.open(path, std::ios::out | std::ios::noreplace);
#else
fs.open(path);
#endif

for (const auto &chrom : chroms) {
fmt::print(fs, "{}\t{}\n", chrom.name(), chrom.size());
Expand Down

0 comments on commit 4865938

Please sign in to comment.