vfs: fix compilation error

This commit is contained in:
DH 2025-04-05 02:09:27 +03:00
parent 9efeba1f9f
commit 08e2ab70b4

View file

@ -1042,42 +1042,40 @@ bool vfs::host::rename(const std::string& from, const std::string& to, const lv2
bool vfs::host::unlink(const std::string& path, [[maybe_unused]] const std::string& dev_root) bool vfs::host::unlink(const std::string& path, [[maybe_unused]] const std::string& dev_root)
{ {
#ifdef _WIN32 #ifdef _WIN32
if (auto device = fs::get_virtual_device(path)) if (std::string_view dev_path; auto device = fs::get_virtual_device(path, &dev_path))
{ {
return device->remove(path); return device->remove(std::string(dev_path));
} }
else
// Rename to special dummy name which will be ignored by VFS (but opened file handles can still read or write it)
std::string dummy = hash_path(path, dev_root, "file");
while (true)
{ {
// Rename to special dummy name which will be ignored by VFS (but opened file handles can still read or write it) if (fs::rename(path, dummy, false))
std::string dummy = hash_path(path, dev_root, "file");
while (true)
{ {
if (fs::rename(path, dummy, false)) break;
{
break;
}
if (fs::g_tls_error != fs::error::exist)
{
return false;
}
dummy = hash_path(path, dev_root, "file");
} }
if (fs::file f{dummy, fs::read + fs::write}) if (fs::g_tls_error != fs::error::exist)
{ {
// Set to delete on close on last handle return false;
FILE_DISPOSITION_INFO disp;
disp.DeleteFileW = true;
SetFileInformationByHandle(f.get_handle(), FileDispositionInfo, &disp, sizeof(disp));
return true;
} }
// TODO: what could cause this and how to handle it dummy = hash_path(path, dev_root, "file");
}
if (fs::file f{dummy, fs::read + fs::write})
{
// Set to delete on close on last handle
FILE_DISPOSITION_INFO disp;
disp.DeleteFileW = true;
SetFileInformationByHandle(f.get_handle(), FileDispositionInfo, &disp, sizeof(disp));
return true; return true;
} }
// TODO: what could cause this and how to handle it
return true;
#else #else
return fs::remove_file(path); return fs::remove_file(path);
#endif #endif