mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 23:41:26 +12:00
Improve vfs::host::unlink on Windows (for sys_fs_rmdir)
Possibly fixes sys_fs_rmdir and other cases of directory removal. Make sure the directory with deleted files always becomes empty. For this purpose, temp files are moved to the root of the device.
This commit is contained in:
parent
cd843bda6e
commit
ccf9543b44
3 changed files with 12 additions and 5 deletions
|
@ -33,6 +33,8 @@ bool vfs::mount(std::string_view vpath, std::string_view path)
|
|||
|
||||
const auto table = g_fxo->get<vfs_manager>();
|
||||
|
||||
// TODO: scan roots of mounted devices for undeleted vfs::host::unlink remnants, and try to delete them (_WIN32 only)
|
||||
|
||||
std::lock_guard lock(table->mutex);
|
||||
|
||||
if (vpath.empty())
|
||||
|
@ -566,13 +568,13 @@ bool vfs::host::rename(const std::string& from, const std::string& to, bool over
|
|||
return true;
|
||||
}
|
||||
|
||||
bool vfs::host::unlink(const std::string& path)
|
||||
bool vfs::host::unlink(const std::string& path, const std::string& dev_root)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (path.size() < 2 || reinterpret_cast<const u16&>(path.front()) != "//"_u16)
|
||||
{
|
||||
// Rename to special dummy name which will be ignored by VFS (but opened file handles can still read or write it)
|
||||
const std::string dummy = fmt::format(u8"%s/$%s%s", fs::get_parent_dir(path), fmt::base57(std::hash<std::string>()(path)), fmt::base57(__rdtsc()));
|
||||
const std::string dummy = fmt::format(u8"%s/$%s%s", dev_root, fmt::base57(std::hash<std::string>()(path)), fmt::base57(__rdtsc()));
|
||||
|
||||
if (!fs::rename(path, dummy, true))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue