MCPcopy Create free account
hub / github.com/Icinga/icinga2 / Commit

Method Commit

lib/base/atomic-file.cpp:92–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92void AtomicFile::Commit()
93{
94 flush();
95
96 auto h ((*this)->handle());
97
98#ifdef _WIN32
99 if (!FlushFileBuffers(h)) {
100 auto err (GetLastError());
101
102 BOOST_THROW_EXCEPTION(win32_error()
103 << boost::errinfo_api_function("FlushFileBuffers")
104 << errinfo_win32_error(err)
105 << boost::errinfo_file_name(m_TempFilename));
106 }
107#else /* _WIN32 */
108 if (fsync(h)) {
109 auto err (errno);
110
111 BOOST_THROW_EXCEPTION(posix_error()
112 << boost::errinfo_api_function("fsync")
113 << boost::errinfo_errno(err)
114 << boost::errinfo_file_name(m_TempFilename));
115 }
116#endif /* _WIN32 */
117
118 close();
119 (void)::close(m_Fd);
120 m_Fd = -1;
121
122 Utility::RenameFile(m_TempFilename, m_Path);
123 m_TempFilename = "";
124}

Callers 5

WriteMethod · 0.45
WriteToFileMethod · 0.45
DumpObjectsMethod · 0.45
FlushMethod · 0.45

Calls 2

win32_errorClass · 0.85
posix_errorClass · 0.85

Tested by

no test coverage detected