FileSystem: Fix FD leak with atomic updated file on Linux
Also add the ability to explicitly commit and check for errors.
This commit is contained in:
@ -1002,7 +1002,7 @@ bool GameDatabase::SaveToCache()
|
||||
const u64 gamedb_ts = Host::GetResourceFileTimestamp("gamedb.yaml", false).value_or(0);
|
||||
|
||||
Error error;
|
||||
FileSystem::AtomicRenamedFile file = FileSystem::CreateAtomicRenamedFile(GetCacheFile(), "wb", &error);
|
||||
FileSystem::AtomicRenamedFile file = FileSystem::CreateAtomicRenamedFile(GetCacheFile(), &error);
|
||||
if (!file)
|
||||
{
|
||||
ERROR_LOG("Failed to open cache file for writing: {}", error.GetDescription());
|
||||
|
||||
@ -646,7 +646,7 @@ bool MemoryCardImage::ExportSave(DataArray* data, const FileInfo& fi, const char
|
||||
if (!ReadFile(*data, fi, &file_data, error))
|
||||
return false;
|
||||
|
||||
auto fp = FileSystem::CreateAtomicRenamedFile(filename, "wb", error);
|
||||
auto fp = FileSystem::CreateAtomicRenamedFile(filename, error);
|
||||
if (!fp)
|
||||
return false;
|
||||
|
||||
|
||||
@ -2910,7 +2910,7 @@ bool System::SaveState(const char* path, Error* error, bool backup_existing_save
|
||||
}
|
||||
}
|
||||
|
||||
auto fp = FileSystem::CreateAtomicRenamedFile(path, "wb", error);
|
||||
auto fp = FileSystem::CreateAtomicRenamedFile(path, error);
|
||||
if (!fp)
|
||||
{
|
||||
Error::AddPrefixFmt(error, "Cannot open '{}': ", Path::GetFileName(path));
|
||||
@ -2930,7 +2930,7 @@ bool System::SaveState(const char* path, Error* error, bool backup_existing_save
|
||||
5.0f);
|
||||
|
||||
VERBOSE_LOG("Saving state took {:.2f} msec", save_timer.GetTimeMilliseconds());
|
||||
return true;
|
||||
return FileSystem::CommitAtomicRenamedFile(fp, error);
|
||||
}
|
||||
|
||||
bool System::SaveStateToBuffer(SaveStateBuffer* buffer, Error* error, u32 screenshot_size /* = 256 */)
|
||||
|
||||
Reference in New Issue
Block a user