summaryrefslogtreecommitdiff
path: root/AK/LexicalPath.h
AgeCommit message (Collapse)Author
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-11-26AK: Make it possible to not `using` AK classes into the global namespaceAndreas Kling
This patch adds the `USING_AK_GLOBALLY` macro which is enabled by default, but can be overridden by build flags. This is a step towards integrating Jakt and AK types.
2022-11-02AK: Add support for mlibc in LexicalPathDennis Bonke
2021-11-22AK: Add LexicalPath::prepend()Tim Schumacher
2021-11-17AK: Convert AK::Format formatting helpers to returning ErrorOr<void>Andreas Kling
This isn't a complete conversion to ErrorOr<void>, but a good chunk. The end goal here is to propagate buffer allocation failures to the caller, and allow the use of TRY() with formatting functions.
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-10-10AK: Implement a way to resolve relative paths lexicallyBen Wiederhake
2021-09-28AK: Accept StringView in LexicalPath::joinRodrigo Tobar
The first argument for LexicalPath::join was a String const&, which resulted in an unnecessary memory copy when invoked with a StringView. Changing the type of the parameter to StringView avoids the extra cost. This was noticed while working on #10230.
2021-06-30AK: Use canonicalized_path in LexicalPath::relative_pathMax Wipfli
This avoids construction of LexicalPath objects.
2021-06-30AK: Add [[nodiscard]] to LexicalPath methods construction objectsMax Wipfli
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+Everywhere: Remove "null state" of LexicalPathMax Wipfli
This removes the default constructor of LexicalPath, and subsequently modifies all its users to accommodate the change.
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+Everywhere: Add and use static APIs for LexicalPathMax Wipfli
The LexicalPath instance methods dirname(), basename(), title() and extension() will be changed to return StringView const& in a further commit. Due to this, users creating temporary LexicalPath objects just to call one of those getters will recieve a StringView const& pointing to a possible freed buffer. To avoid this, static methods for those APIs have been added, which will return a String by value to avoid those problems. All cases where temporary LexicalPath objects have been used as described above haven been changed to use the static APIs.
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-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-02-20AK: Add LexicalPath::relative_pathItamar
2021-01-12AK: Simplify constructors and conversions from nullptr_tLenny Maiorani
Problem: - Many constructors are defined as `{}` rather than using the ` = default` compiler-provided constructor. - Some types provide an implicit conversion operator from `nullptr_t` instead of requiring the caller to default construct. This violates the C++ Core Guidelines suggestion to declare single-argument constructors explicit (https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit). Solution: - Change default constructors to use the compiler-provided default constructor. - Remove implicit conversion operators from `nullptr_t` and change usage to enforce type consistency without conversion.
2020-12-30AK+Format: Remove TypeErasedFormatParams& from format function.asynts
2020-10-09AK: Add formatter for LexcialPath.asynts
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.