From 0979c692de31f60fc9f6bafffa1c65336d28f706 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 14 Dec 2022 06:44:11 +0100 Subject: [PATCH] COMMON: Add new method joinComponents --- common/path.cpp | 14 ++++++++++++++ common/path.h | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/common/path.cpp b/common/path.cpp index daaac85f3c6..7adb03e01b3 100644 --- a/common/path.cpp +++ b/common/path.cpp @@ -276,6 +276,20 @@ Path Path::punycodeDecode() const { return ret; } +Path Path::joinComponents(const StringArray& c) { + String res; + + for (uint i = 0; i < c.size(); i++) { + res += c[i]; + if (i + 1 < c.size()) + res += DIR_SEPARATOR; + } + + Path ret; + ret._str = res; + return ret; +} + // See getIdentifierString() for more details. // This does the same but for a single path component and is used by // getIdentifierString(). diff --git a/common/path.h b/common/path.h index 8145bd2d6ac..3d3a5f087e3 100644 --- a/common/path.h +++ b/common/path.h @@ -215,6 +215,12 @@ public: * 2 separots follow each other */ StringArray splitComponents() const; + + + /** + * Opposite of splitComponents + */ + static Path joinComponents(const StringArray& c); }; /** @} */