feat: add getRelativePath

This commit is contained in:
2026-05-11 08:07:12 -03:00
parent 9d3b5d25b2
commit 4a0d387328
2 changed files with 25 additions and 0 deletions
+22
View File
@@ -257,6 +257,28 @@ std::string VirtualFileSystem::trimPathSeparators(const std::string& path)
return path.substr(start, end - start + 1);
}
bool VirtualFileSystem::getRelativePath(const MountPoint& mount, const std::string& searchPath,
std::string& outRelative) const
{
if (searchPath == mount.virtualPath)
{
outRelative = "/";
return true;
}
if (mount.virtualPath == "/")
{
outRelative = searchPath;
return true;
}
std::string prefix = mount.virtualPath + '/';
if (searchPath.compare(0, prefix.length(), prefix) == 0)
{
outRelative = searchPath.substr(prefix.length());
return true;
}
return false;
}
/*
mountpoint
*/
+3
View File
@@ -99,6 +99,9 @@ namespace seallib
static bool isPathSeparator(char c);
static std::string trimPathSeparators(const std::string& path);
bool getRelativePath(const MountPoint& mount, const std::string& searchPath,
std::string& outRelative) const;
};
inline std::string vfsResultToString(VFSResult result)