fix: iterate through mounts instead of getting best mount

This commit is contained in:
2026-05-11 08:07:05 -03:00
parent 0fbf8c715c
commit 9d3b5d25b2
+28 -11
View File
@@ -87,20 +87,32 @@ void VirtualFileSystem::unmountAll()
bool VirtualFileSystem::exists(const std::string& path) const
{
std::shared_lock lock(_mutex);
std::string relativePath;
const MountPoint* mount = findBestMount(path, relativePath);
std::string searchPath = trimPathSeparators(normalizePath(path));
return mount ? mount->provider->exists(relativePath) : false;
for (const auto& mount : _mounts)
{
std::string relativePath;
if (getRelativePath(mount, searchPath, relativePath))
{
if (mount.provider->exists(relativePath)) return true;
}
}
return false;
}
VFSResult VirtualFileSystem::readFile(const std::string& path, FileBuffer& outBuffer) const
{
std::shared_lock lock(_mutex);
std::string relativePath;
const MountPoint* mount = findBestMount(path, relativePath);
std::string searchPath = trimPathSeparators(normalizePath(path));
if (!mount) return VFSResult::FileNotFound;
return mount->provider->readFile(relativePath, outBuffer);
for (const auto& mount : _mounts)
{
std::string relativePath;
if (getRelativePath(mount, searchPath, relativePath))
if (mount.provider->exists(relativePath)) return mount.provider->readFile(relativePath, outBuffer);
}
return VFSResult::FileNotFound;
}
VFSResult VirtualFileSystem::writeFile(const std::string& path, const FileBuffer& buffer)
@@ -118,11 +130,16 @@ VFSResult VirtualFileSystem::writeFile(const std::string& path, const FileBuffer
VFSResult VirtualFileSystem::deleteFile(const std::string& path)
{
std::shared_lock lock(_mutex);
std::string relativePath;
MountPoint* mount = findBestMount(path, relativePath);
std::string searchPath = trimPathSeparators(normalizePath(path));
if (!mount) return VFSResult::FileNotFound;
return mount->provider->deleteFile(relativePath);
for (auto& mount : _mounts)
{
std::string relativePath;
if (getRelativePath(mount, searchPath, relativePath))
if (mount.provider->exists(relativePath)) return mount.provider->deleteFile(relativePath);
}
return VFSResult::FileNotFound;
}
VFSResult VirtualFileSystem::createDirectory(const std::string& path)