From 9d3b5d25b2f8bb477e0e738cfdc57de3e2ebb0d6 Mon Sep 17 00:00:00 2001 From: neru Date: Mon, 11 May 2026 08:07:05 -0300 Subject: [PATCH] fix: iterate through mounts instead of getting best mount --- src/lib/seallib/vfs.cpp | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/lib/seallib/vfs.cpp b/src/lib/seallib/vfs.cpp index 82a241a..29ed82e 100644 --- a/src/lib/seallib/vfs.cpp +++ b/src/lib/seallib/vfs.cpp @@ -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)