mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-25 04:02:42 +01:00
Fix atomicity of savedata/trophy data writes
This commit is contained in:
parent
932f31e37b
commit
d4af8dd89a
@ -748,7 +748,7 @@ namespace fs
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
template <bool Flush = false, typename... Args>
|
||||||
bool write_file(const std::string& path, bs_t<fs::open_mode> mode, const Args&... args)
|
bool write_file(const std::string& path, bs_t<fs::open_mode> mode, const Args&... args)
|
||||||
{
|
{
|
||||||
// Always use write flag, remove read flag
|
// Always use write flag, remove read flag
|
||||||
@ -758,14 +758,19 @@ namespace fs
|
|||||||
{
|
{
|
||||||
// Specialization for [const void*, usz] args
|
// Specialization for [const void*, usz] args
|
||||||
f.write(args...);
|
f.write(args...);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Write args sequentially
|
// Write args sequentially
|
||||||
(f.write(args), ...);
|
(f.write(args), ...);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if constexpr (Flush)
|
||||||
|
{
|
||||||
|
f.sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -1911,7 +1911,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
|
|||||||
if (auto file = pair.second.release())
|
if (auto file = pair.second.release())
|
||||||
{
|
{
|
||||||
auto fvec = static_cast<fs::container_stream<std::vector<uchar>>&>(*file);
|
auto fvec = static_cast<fs::container_stream<std::vector<uchar>>&>(*file);
|
||||||
fs::file(new_path + vfs::escape(pair.first), fs::rewrite).write(fvec.obj);
|
ensure(fs::write_file<true>(new_path + vfs::escape(pair.first), fs::rewrite, fvec.obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ bool TRPLoader::Install(const std::string& dest, bool show)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the file in the temporary directory
|
// Create the file in the temporary directory
|
||||||
success = fs::write_file(temp + '/' + vfs::escape(entry.name), fs::create + fs::excl, buffer);
|
success = fs::write_file<true>(temp + '/' + vfs::escape(entry.name), fs::create + fs::excl, buffer);
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user