From 07351762c75e248d8bf77a2972e0527f02a7fa75 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sun, 21 Nov 2021 19:55:44 +0100 Subject: [PATCH] AK: Add LexicalPath::prepend() --- AK/LexicalPath.cpp | 5 +++++ AK/LexicalPath.h | 1 + 2 files changed, 6 insertions(+) diff --git a/AK/LexicalPath.cpp b/AK/LexicalPath.cpp index 7864c13983b..a80d11236d8 100644 --- a/AK/LexicalPath.cpp +++ b/AK/LexicalPath.cpp @@ -164,6 +164,11 @@ LexicalPath LexicalPath::append(StringView value) const return LexicalPath::join(m_string, value); } +LexicalPath LexicalPath::prepend(StringView value) const +{ + return LexicalPath::join(value, m_string); +} + LexicalPath LexicalPath::parent() const { return append(".."); diff --git a/AK/LexicalPath.h b/AK/LexicalPath.h index d758e9ad199..54de3497086 100644 --- a/AK/LexicalPath.h +++ b/AK/LexicalPath.h @@ -30,6 +30,7 @@ public: bool has_extension(StringView) const; [[nodiscard]] LexicalPath append(StringView) const; + [[nodiscard]] LexicalPath prepend(StringView) const; [[nodiscard]] LexicalPath parent() const; [[nodiscard]] static String canonicalized_path(String);