This better conveys the semantics.
AtomicFile::~AtomicFile()
{
if (m_stream) {
- // close() was not called so remove the lingering temporary file.
+ // commit() was not called so remove the lingering temporary file.
fclose(m_stream);
tmp_unlink(m_tmp_path.c_str());
}
}
void
-AtomicFile::close()
+AtomicFile::commit()
{
assert(m_stream);
fclose(m_stream);
// Close the temporary file and rename it to the destination file. Note: The
// destructor will not do this automatically to avoid half-written data in the
// file.
- void close();
+ void commit();
private:
const std::string m_path;
output.write(fmt::format("{} = {}\n", key, value));
}
- output.close();
+ output.commit();
}
void