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:
Nekotekina 2019-09-25 04:57:56 +03:00
parent cd843bda6e
commit ccf9543b44
3 changed files with 12 additions and 5 deletions

View file

@ -862,7 +862,9 @@ error_code sys_fs_unlink(ppu_thread& ppu, vm::cptr<char> path)
const std::string_view vpath = path.get_ptr();
const std::string local_path = vfs::get(vpath);
if (vpath.find_first_not_of('/') == -1)
const std::size_t dev_start = vpath.find_first_not_of('/');
if (dev_start == -1)
{
return {CELL_EISDIR, path};
}
@ -877,7 +879,10 @@ error_code sys_fs_unlink(ppu_thread& ppu, vm::cptr<char> path)
return {CELL_EISDIR, path};
}
if (!vfs::host::unlink(local_path))
// Size of "/dev_hdd0"-alike substring
const std::size_t dev_size = vpath.find_first_of('/', dev_start);
if (!vfs::host::unlink(local_path, vfs::get(vpath.substr(0, dev_size))))
{
switch (auto error = fs::g_tls_error)
{