diff --git a/Utilities/File.cpp b/Utilities/File.cpp index 7a9980799b..9c521f635d 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -946,6 +946,16 @@ bool fs::utime(const std::string& path, s64 atime, s64 mtime) #endif } +void fs::sync() +{ +#ifdef _WIN32 + fs::g_tls_error = fs::error::unknown; +#else + ::sync(); + fs::g_tls_error = fs::error::ok; +#endif +} + [[noreturn]] void fs::xnull(const src_loc& loc) { fmt::throw_exception("Null object.%s", loc); diff --git a/Utilities/File.h b/Utilities/File.h index 865f5117c3..2fe7e2b526 100644 --- a/Utilities/File.h +++ b/Utilities/File.h @@ -193,6 +193,9 @@ namespace fs // Set file access/modification time bool utime(const std::string& path, s64 atime, s64 mtime); + // Synchronize filesystems (TODO) + void sync(); + class file final { std::unique_ptr m_file; diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index 7a7d757cdc..d879a64ace 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -1929,6 +1929,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v // Remove old backup fs::remove_all(old_path); + fs::sync(); // Backup old savedata if (!vfs::host::rename(dir_path, old_path, &g_mp_sys_dev_hdd0, false))