mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 05:51:27 +12: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
3 changed files with 21 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue