mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
fs: alternative fs::pending_file implementation (Win32)
Use MOVEFILE_WRITE_THROUGH instead of sync() on commit().
This commit is contained in:
parent
aaa20c0ff0
commit
3c614d95b8
@ -1984,15 +1984,31 @@ bool fs::pending_file::commit(bool overwrite)
|
||||
}
|
||||
|
||||
// The temporary file's contents must be on disk before rename
|
||||
#ifndef _WIN32
|
||||
file.sync();
|
||||
#endif
|
||||
file.close();
|
||||
|
||||
#ifdef _WIN32
|
||||
const auto ws1 = to_wchar(m_path);
|
||||
const auto ws2 = to_wchar(m_dest);
|
||||
|
||||
if (MoveFileExW(ws1.get(), ws2.get(), overwrite ? MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH : MOVEFILE_WRITE_THROUGH))
|
||||
{
|
||||
// Disable the destructor
|
||||
m_path.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
g_tls_error = to_error(GetLastError());
|
||||
#else
|
||||
if (fs::rename(m_path, m_dest, overwrite))
|
||||
{
|
||||
// Disable the destructor
|
||||
m_path.clear();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -649,6 +649,8 @@ namespace fs
|
||||
bool commit(bool overwrite = true);
|
||||
|
||||
pending_file(const std::string& path);
|
||||
pending_file(const pending_file&) = delete;
|
||||
pending_file& operator=(const pending_file&) = delete;
|
||||
~pending_file();
|
||||
|
||||
private:
|
||||
|
@ -1946,7 +1946,9 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
|
||||
if (auto file = pair.second.release())
|
||||
{
|
||||
auto&& fvec = static_cast<fs::container_stream<std::vector<uchar>>&>(*file);
|
||||
ensure(fs::write_file<true>(new_path + vfs::escape(pair.first), fs::rewrite, fvec.obj));
|
||||
fs::pending_file f(new_path + vfs::escape(pair.first));
|
||||
f.file.write(fvec.obj);
|
||||
ensure(f.commit());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user