1 #ifndef CASM_SafeOfstream
2 #define CASM_SafeOfstream
4 #include <boost/filesystem.hpp>
5 #include <boost/filesystem/fstream.hpp>
65 void open(fs::path
name, std::string tmp_ext =
"tmp") {
70 throw std::runtime_error(
71 std::string(
"Error in 'SafeOfstream::open(fs::path name, std::string "
73 " File: " +
m_tmp_name.string() +
" already exists");
Write to a temporary file to ensure a good write, then rename.
void close()
Closes stream, and if not a failed write, removes "file" and renames "file.tmp" to "file".
void open(fs::path name, std::string tmp_ext="tmp")
Opens "file.tmp" for writing, with intended final target "file".
fs::ofstream & ofstream()
Access underlying stream.
GenericDatumFormatter< std::string, DataObject > name()