void History::Save() { try { FS::File f = FS::HomePath::OpenWrite(GetFilename()); auto lock = Lock(); Container::size_type i = 0; if ( lines.size() > SAVED_HISTORY_LINES ) i = lines.size() - SAVED_HISTORY_LINES; for (; i < lines.size(); i++) { f.Write(lines[i].data(), lines[i].size()); f.Write("\n", 1); } } catch (const std::system_error& error) { Log::Warn("Couldn't write %s: %s", GetFilename(), error.what()); } }
void FS_WriteFile(const char* path, const void* buffer, int size) { try { FS::File f = FS::HomePath::OpenWrite(path); f.Write(buffer, size); f.Close(); } catch (std::system_error& err) { Log::Notice("Failed to write file '%s': %s\n", path, err.what()); } }