Commit Graph

4 Commits

Author SHA1 Message Date
Andreas Kling
56a2594de7 Kernel: Make KString factories return KResultOr + use TRY() everywhere
There are a number of places that don't have an error propagation path
right now, so I've added FIXME's about that.
2021-09-06 19:25:36 +02:00
Max Wipfli
9ab528ff5c Kernel: Make KLexicalPath::basename() more compliant
This removes some assertions from KLexicalPath::basename() by supporting
paths with trailing slashes, empty paths, paths consisting of only
slashes and paths with ending "." and ".." segments.
2021-07-11 14:10:58 +02:00
Max Wipfli
1f792faf34 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.
2021-07-07 15:32:17 +02:00
Max Wipfli
87a62f4def Kernel: Add KLexicalPath
This adds KLexicalPath, which are a few static functions which aim to
mostly emulate AK::LexicalPath. They are however constrained to work
with absolute paths only, containing no '.' or '..' path segments and no
consecutive slashes. This way, it is possible to avoid use StringView
for the return values and thus avoid allocating new String objects.

As explained above, the functions are currently very strict about the
allowed input paths. This seems to not be a problem currently. Since the
functions VERIFY this, potential bugs caused by this will become
immediately obvious.
2021-07-07 15:32:17 +02:00