libluna: Add a variant of PathParser::join() for relative paths

This commit is contained in:
apio 2023-07-02 16:38:12 +02:00
parent dd914b16d1
commit 6db0a2649c
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 9 additions and 3 deletions

View File

@ -17,6 +17,7 @@ class PathParser
PathParser(const PathParser&) = delete;
static Result<String> join(StringView path1, StringView path2);
static Result<String> join_paths(StringView path1, StringView path2);
static Result<String> realpath(StringView path);

View File

@ -62,6 +62,13 @@ Result<String> PathParser::dirname(StringView path)
}
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;
TRY(sb.add(path1));
@ -70,9 +77,7 @@ Result<String> PathParser::join(StringView path1, StringView path2)
TRY(sb.add(path2));
String result = TRY(sb.string());
return realpath(result.view());
return sb.string();
}
Result<String> PathParser::realpath(StringView path)