Introduce AtomicFile::Write()

This commit is contained in:
Alexander A. Klimov 2022-08-01 17:07:00 +02:00
parent 11e37a0bd1
commit a3e205b990
2 changed files with 9 additions and 0 deletions

View File

@ -15,6 +15,13 @@
using namespace icinga;
void AtomicFile::Write(String path, int mode, const String& content)
{
AtomicFile af (path, mode);
af << content;
af.Commit();
}
AtomicFile::AtomicFile(String path, int mode) : m_Path(std::move(path))
{
m_TempFilename = m_Path + ".tmp.XXXXXX";

View File

@ -18,6 +18,8 @@ namespace icinga
class AtomicFile : public boost::iostreams::stream<boost::iostreams::file_descriptor>
{
public:
static void Write(String path, int mode, const String& content);
AtomicFile(String path, int mode);
~AtomicFile();