1 #ifndef GENESIS_UTILS_IO_OUTPUT_STREAM_H_ 2 #define GENESIS_UTILS_IO_OUTPUT_STREAM_H_ 69 std::string
const& filename,
70 std::ofstream& out_stream,
71 std::ios_base::openmode mode = std::ios_base::out
75 "File '" + filename +
"' already exists. If you want to allow overwriting of existing " 76 "files, activate genesis::utils::Options::get().allow_file_overwriting() first.",
81 out_stream.open( filename, mode );
82 if( out_stream.fail() ) {
83 throw std::runtime_error(
"Cannot write to file '" + filename +
"'." );
90 #endif // include guard Exception class that is thrown if trying to write to an existing file.
void file_output_stream(std::string const &filename, std::ofstream &out_stream, std::ios_base::openmode mode=std::ios_base::out)
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 file_exists(std::string const &filename)
Return true iff the file exists.
Provides functions for accessing the file system.
static Options & get()
Returns a single instance of this class.