summaryrefslogtreecommitdiff
path: root/Kernel/KLexicalPath.cpp
AgeCommit message (Collapse)Author
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-10AK+Everywhere: Stop including Vector.h from StringView.hAndreas Kling
Preparation for using Error.h from Vector.h. This required moving some things out of line.
2021-11-08Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>Andreas Kling
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace! This was a slightly tedious refactoring that took a long time, so it's not unlikely that some bugs crept in. Nevertheless, it does pass basic functionality testing, and it's just real nice to finally see the same pattern in all contexts. :^)
2021-09-06Kernel: Make KString factories return KResultOr + use TRY() everywhereAndreas Kling
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-07-11Kernel: Make KLexicalPath::basename() more compliantMax Wipfli
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-07Kernel: Add KLexicalPath::try_join and use itMax Wipfli
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-07Kernel: Add KLexicalPathMax Wipfli
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.