summaryrefslogtreecommitdiff
path: root/AK/LexicalPath.cpp
AgeCommit message (Collapse)Author
2022-12-14AK: Create relative path even if prefix is not an ancestor of the pathPoseydon42
2022-12-11AK: Add LexicalPath::is_child_ofkleines Filmröllchen
This API checks whether this path is a child of (or the same as) another path.
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
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-22AK: Add LexicalPath::prepend()Tim Schumacher
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-10-10AK: Implement a way to resolve relative paths lexicallyBen Wiederhake
2021-07-02AK+Everywhere: Remove StringView::find_{first,last}_of(char) methodsMax Wipfli
This removes StringView::find_first_of(char) and find_last_of(char) and replaces all its usages with find and find_last respectively. This is because those two methods are functionally equivalent. find_{first,last}_of should only be used if searching for multiple different characters, which is never the case with the char argument. This also adds the [[nodiscard]] to the remaining find_{first,last}_of methods.
2021-06-30AK: Use canonicalized_path in LexicalPath::relative_pathMax Wipfli
This avoids construction of LexicalPath objects.
2021-06-30AK: Move path canonicalization into LexicalPath::canonicalized_pathMax Wipfli
This moves the path canonicalization from the LexicalPath constructor to canonicalized_path. This allows canonicalized path to no longer construct a LexicalPath object and initialize all its member variables.
2021-06-30AK: Make LexicalPath immutableMax Wipfli
This replaces the current LexicalPath::append() API with a new method that returns a new LexicalPath object and doesn't touch the this-object. With this, LexicalPath is now immutable. It also adds a LexicalPath::parent() method and the relevant test cases.
2021-06-30AK+Everywhere: Use mostly StringView in LexicalPathMax Wipfli
This changes the m_parts, m_dirname, m_basename, m_title and m_extension member variables to StringViews onto the m_string String. It also removes the m_is_absolute member in favour of computing if a path is absolute in the is_absolute() getter. Due to this, the canonicalize() method has been completely rewritten. The parts() getter still returns a Vector<String>, although it is no longer a const reference as m_parts is no longer a Vector<String>. Rather, it is constructed from the StringViews in m_parts upon request. The parts_view() getter has been added, which returns Vector<StringView> const&. Most previous users of parts() have been changed to use parts_view(), except where Strings are required. Due to this change, it's is now no longer allow to create temporary LexicalPath objects to call the dirname, basename, title, or extension getters on them because the returned StringViews will point to possible freed memory.
2021-06-30AK: Remove the LexicalPath::is_valid() APIMax Wipfli
Since this is always set to true on the non-default constructor and subsequently never modified, it is somewhat pointless. Furthermore, there are arguably no invalid relative paths.
2021-06-30AK: Use east const style in LexicalPath.{cpp,h}Max Wipfli
2021-05-27LexicalPath: Reset dirname if it's emptyTim Schumacher
dirname ends up empty if the canonical path only contains one element. Reset it to the default for relative/absolute paths if that is the case.
2021-05-18AK: Make LexicalPath handle relative paths correctlyGunnar Beutner
Previously LexicalPath would consider "." and ".." as equivalent to "/". This is not true though.
2021-05-12AK: Add LexicalPath::append and LexicalPath::joinsin-ack
This patch adds two new methods to LexicalPath. LexicalPath::append appends a new path component to a LexicalPath, and LexicalPath::join constructs a new LexicalPath from one or more components. Co-authored-by: Gunnar Beutner <gunnar@beutner.name>
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-17AK: Make LexicalPath take String instead of StringViewAndreas Kling
2021-04-11AK: Update LexicalPath::relative_path to work for '/' prefixTim Waterhouse
If the prefix path is just a slash the LexicalPath was removing too many characters. Now only remove an extra character if the prefix is not just the root path.
2021-02-20AK: Add LexicalPath::relative_pathItamar
2020-09-25Meta+AK: Make clang-format-10 cleanBen Wiederhake
2020-07-15LexicalPath: Simplify a loopNico Weber
No behavior change.
2020-07-13AK: Make LexicalPath keep everything before the last dot as titleNico Weber
Previously, TextEditor would put "foo.txt" in the Save As dialog for files named "foo.bar.txt". Now, it puts "foo.bar.txt" instead.
2020-05-26AK: Rename FileSystemPath -> LexicalPathSergey Bugaev
And move canonicalized_path() to a static method on LexicalPath. This is to make it clear that FileSystemPath/canonicalized_path() only perform *lexical* canonicalization.