feat: add getRelativePath
This commit is contained in:
@@ -257,6 +257,28 @@ std::string VirtualFileSystem::trimPathSeparators(const std::string& path)
|
|||||||
return path.substr(start, end - start + 1);
|
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
|
mountpoint
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ namespace seallib
|
|||||||
|
|
||||||
static bool isPathSeparator(char c);
|
static bool isPathSeparator(char c);
|
||||||
static std::string trimPathSeparators(const std::string& path);
|
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)
|
inline std::string vfsResultToString(VFSResult result)
|
||||||
|
|||||||
Reference in New Issue
Block a user