| 232 | } |
| 233 | |
| 234 | bool 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 | |
| 252 | void AppendFileToFile(string const & fromFilename, string const & toFilename) |
| 253 | { |
no test coverage detected