libluna: Add a variant of PathParser::join() for relative paths
This commit is contained in:
parent
dd914b16d1
commit
6db0a2649c
@ -17,6 +17,7 @@ class PathParser
|
|||||||
PathParser(const PathParser&) = delete;
|
PathParser(const PathParser&) = delete;
|
||||||
|
|
||||||
static Result<String> join(StringView path1, StringView path2);
|
static Result<String> join(StringView path1, StringView path2);
|
||||||
|
static Result<String> join_paths(StringView path1, StringView path2);
|
||||||
|
|
||||||
static Result<String> realpath(StringView path);
|
static Result<String> realpath(StringView path);
|
||||||
|
|
||||||
|
@ -62,6 +62,13 @@ Result<String> PathParser::dirname(StringView path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result<String> PathParser::join(StringView path1, StringView path2)
|
Result<String> PathParser::join(StringView path1, StringView path2)
|
||||||
|
{
|
||||||
|
String result = TRY(join_paths(path1, path2));
|
||||||
|
|
||||||
|
return realpath(result.view());
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<String> PathParser::join_paths(StringView path1, StringView path2)
|
||||||
{
|
{
|
||||||
StringBuilder sb;
|
StringBuilder sb;
|
||||||
TRY(sb.add(path1));
|
TRY(sb.add(path1));
|
||||||
@ -70,9 +77,7 @@ Result<String> PathParser::join(StringView path1, StringView path2)
|
|||||||
|
|
||||||
TRY(sb.add(path2));
|
TRY(sb.add(path2));
|
||||||
|
|
||||||
String result = TRY(sb.string());
|
return sb.string();
|
||||||
|
|
||||||
return realpath(result.view());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<String> PathParser::realpath(StringView path)
|
Result<String> PathParser::realpath(StringView path)
|
||||||
|
Loading…
Reference in New Issue
Block a user