fix: iterate through mounts instead of getting best mount
This commit is contained in:
+28
-11
@@ -87,20 +87,32 @@ void VirtualFileSystem::unmountAll()
|
|||||||
bool VirtualFileSystem::exists(const std::string& path) const
|
bool VirtualFileSystem::exists(const std::string& path) const
|
||||||
{
|
{
|
||||||
std::shared_lock lock(_mutex);
|
std::shared_lock lock(_mutex);
|
||||||
std::string relativePath;
|
std::string searchPath = trimPathSeparators(normalizePath(path));
|
||||||
const MountPoint* mount = findBestMount(path, relativePath);
|
|
||||||
|
|
||||||
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
|
VFSResult VirtualFileSystem::readFile(const std::string& path, FileBuffer& outBuffer) const
|
||||||
{
|
{
|
||||||
std::shared_lock lock(_mutex);
|
std::shared_lock lock(_mutex);
|
||||||
std::string relativePath;
|
std::string searchPath = trimPathSeparators(normalizePath(path));
|
||||||
const MountPoint* mount = findBestMount(path, relativePath);
|
|
||||||
|
|
||||||
if (!mount) return VFSResult::FileNotFound;
|
for (const auto& mount : _mounts)
|
||||||
return mount->provider->readFile(relativePath, outBuffer);
|
{
|
||||||
|
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)
|
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)
|
VFSResult VirtualFileSystem::deleteFile(const std::string& path)
|
||||||
{
|
{
|
||||||
std::shared_lock lock(_mutex);
|
std::shared_lock lock(_mutex);
|
||||||
std::string relativePath;
|
std::string searchPath = trimPathSeparators(normalizePath(path));
|
||||||
MountPoint* mount = findBestMount(path, relativePath);
|
|
||||||
|
|
||||||
if (!mount) return VFSResult::FileNotFound;
|
for (auto& mount : _mounts)
|
||||||
return mount->provider->deleteFile(relativePath);
|
{
|
||||||
|
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)
|
VFSResult VirtualFileSystem::createDirectory(const std::string& path)
|
||||||
|
|||||||
Reference in New Issue
Block a user