mirror of https://github.com/Icinga/icinga2.git
Introduce AtomicFile::Write()
This commit is contained in:
parent
11e37a0bd1
commit
a3e205b990
|
@ -15,6 +15,13 @@
|
||||||
|
|
||||||
using namespace icinga;
|
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))
|
AtomicFile::AtomicFile(String path, int mode) : m_Path(std::move(path))
|
||||||
{
|
{
|
||||||
m_TempFilename = m_Path + ".tmp.XXXXXX";
|
m_TempFilename = m_Path + ".tmp.XXXXXX";
|
||||||
|
|
|
@ -18,6 +18,8 @@ namespace icinga
|
||||||
class AtomicFile : public boost::iostreams::stream<boost::iostreams::file_descriptor>
|
class AtomicFile : public boost::iostreams::stream<boost::iostreams::file_descriptor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static void Write(String path, int mode, const String& content);
|
||||||
|
|
||||||
AtomicFile(String path, int mode);
|
AtomicFile(String path, int mode);
|
||||||
~AtomicFile();
|
~AtomicFile();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue