SafeFile.h file
Functions
- auto WriteFileSafely(const std::string& path, std::string_view data, std::string* error = nullptr) -> bool
Function documentation
bool WriteFileSafely(const std::string& path, std::string_view data, std::string* error = nullptr)
Write data to path so that a crash, a full disk or a failed write never leaves it half written: the data goes to a temporary file beside it, which then replaces it in one rename. Creates the folder if needed. False if anything failed, with the old file left as it was and the reason in error.