Kernel: Add KLexicalPath::try_join and use it

This adds KLexicalPath::try_join(). As this cannot be done without
allocation, it uses KString and can fail. This patch also uses it at one
place. All the other cases of String::formatted("{}/{}", ...) currently
rely on the return value being a String, which means they cannot easily
be converted to use the new API.
This commit is contained in:
Max Wipfli 2021-07-06 12:05:50 +02:00 committed by Andreas Kling
commit 1f792faf34
Notes: sideshowbarker 2024-07-18 10:14:13 +09:00
3 changed files with 35 additions and 1 deletions

View file

@ -7,6 +7,7 @@
#pragma once
#include <AK/StringView.h>
#include <Kernel/KString.h>
namespace Kernel::KLexicalPath {
@ -16,4 +17,6 @@ StringView basename(StringView const&);
StringView dirname(StringView const&);
Vector<StringView> parts(StringView const&);
OwnPtr<KString> try_join(StringView const&, StringView const&);
}