|
A library for working with phylogenetic and population genetic data.
v0.27.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_UTILS_IO_OUTPUT_STREAM_H_
2 #define GENESIS_UTILS_IO_OUTPUT_STREAM_H_
70 std::string
const& filename,
71 std::ofstream& out_stream,
72 std::ios_base::openmode mode = std::ios_base::out,
73 bool create_dirs =
true
77 "File '" + filename +
"' already exists. If you want to allow overwriting of existing "
78 "files, activate genesis::utils::Options::get().allow_file_overwriting() first.",
88 out_stream.open( filename, mode );
89 if( out_stream.fail() ) {
90 throw std::runtime_error(
"Cannot write to file '" + filename +
"'." );
97 #endif // include guard
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)
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
bool file_exists(std::string const &filename)
Return true iff the file exists.
Exception class that is thrown if trying to write to an existing file.
static Options & get()
Returns a single instance of this class.
void file_output_stream(std::string const &filename, 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.