CASM
AClustersApproachtoStatisticalMechanics
|
#include <SafeOfstream.hh>
Write to a temporary file to ensure a good write, then rename.
Definition at line 28 of file SafeOfstream.hh.
Public Member Functions | |
SafeOfstream () | |
void | open (fs::path name, std::string tmp_ext="tmp") |
Opens "file.tmp" for writing, with intended final target "file". More... | |
fs::ofstream & | ofstream () |
Access underlying stream. More... | |
void | close () |
Closes stream, and if not a failed write, removes "file" and renames "file.tmp" to "file". More... | |
Private Attributes | |
fs::path | m_name |
fs::path | m_tmp_name |
fs::ofstream | m_sout |
|
inline |
Definition at line 32 of file SafeOfstream.hh.
|
inline |
Closes stream, and if not a failed write, removes "file" and renames "file.tmp" to "file".
Definition at line 81 of file SafeOfstream.hh.
|
inline |
Access underlying stream.
Definition at line 76 of file SafeOfstream.hh.
|
inline |
Opens "file.tmp" for writing, with intended final target "file".
name | Name of target file |
tmp_ext | String to be used as an extension for the temporary file that is written |
if | name.tmp_ext already exists |
Example:
Definition at line 62 of file SafeOfstream.hh.
|
private |
Definition at line 91 of file SafeOfstream.hh.
|
private |
Definition at line 93 of file SafeOfstream.hh.
|
private |
Definition at line 92 of file SafeOfstream.hh.