|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_UTILS_IO_OUTPUT_STREAM_H_
2 #define GENESIS_UTILS_IO_OUTPUT_STREAM_H_
73 std::string
const& file_name,
74 std::ofstream& out_stream,
75 std::ios_base::openmode mode = std::ios_base::out,
76 bool create_dirs =
true
81 "Output path '" + file_name +
"' already exists. If you want to allow overwriting of "
82 "existing files, activate genesis::utils::Options::get().allow_file_overwriting() first.",
95 out_stream.open( file_name, mode );
96 if( !out_stream.is_open() || out_stream.fail() ) {
97 throw std::runtime_error(
98 "Cannot open output file '" + file_name +
"': " + std::string( strerror( errno ))
106 #endif // include guard
Exception class that is thrown if trying to write to an existing file.
Provides functions for accessing the file system.
void dir_create(std::string const &path, bool with_parents)
Create a directory.
std::string file_path(std::string const &filename)
Return the path leading to a file.
utils::Range< IteratorPath< true > > path(ElementType const &start, ElementType const &finish)
void file_output_stream(std::string const &file_name, std::ofstream &out_stream, std::ios_base::openmode mode=std::ios_base::out, bool create_dirs=true)
Helper function to obtain an output stream to a file.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
bool path_exists(std::string const &path)
Return whether a path exists, i.e., is a file or directory.
static Options & get()
Returns a single instance of this class.