strip leading '/' in fs::AppendPath().

This commit is contained in:
ITotalJustice
2025-06-07 11:54:56 +01:00
parent 8d958a2d1d
commit 16c074db1a

View File

@@ -93,12 +93,18 @@ bool is_read_only(std::string_view path) {
} // namespace
FsPath AppendPath(const FsPath& root_path, const FsPath& file_path) {
FsPath AppendPath(const FsPath& root_path, const FsPath& _file_path) {
// strip leading '/' in file path.
auto file_path = _file_path.s;
while (file_path[0] == '/') {
file_path++;
}
FsPath path;
if (root_path[std::strlen(root_path) - 1] != '/') {
std::snprintf(path, sizeof(path), "%s/%s", root_path.s, file_path.s);
std::snprintf(path, sizeof(path), "%s/%s", root_path.s, file_path);
} else {
std::snprintf(path, sizeof(path), "%s%s", root_path.s, file_path.s);
std::snprintf(path, sizeof(path), "%s%s", root_path.s, file_path);
}
return path;
}