MCPcopy Create free account
hub / github.com/comaps/comaps / WriteToTempAndRenameToFile

Function WriteToTempAndRenameToFile

libs/coding/internal/file_data.cpp:234–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234bool WriteToTempAndRenameToFile(string const & dest, function<bool(string const &)> const & write, string const & tmp)
235{
236 string const tmpFileName = tmp.empty() ? dest + ".tmp" + strings::to_string(this_thread::get_id()) : tmp;
237 if (!write(tmpFileName))
238 {
239 LOG(LERROR, ("Can't write to", tmpFileName));
240 DeleteFileX(tmpFileName);
241 return false;
242 }
243 if (!RenameFileX(tmpFileName, dest))
244 {
245 LOG(LERROR, ("Can't rename file", tmpFileName, "to", dest));
246 DeleteFileX(tmpFileName);
247 return false;
248 }
249 return true;
250}
251
252void AppendFileToFile(string const & fromFilename, string const & toFilename)
253{

Callers 4

SaveFunction · 0.85
SaveMethod · 0.85
SaveKmlFileSafeFunction · 0.85
SaveMethod · 0.85

Calls 5

to_stringFunction · 0.85
writeFunction · 0.85
DeleteFileXFunction · 0.85
RenameFileXFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected