aboutsummaryrefslogtreecommitdiff
path: root/common/str.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/str.cpp')
-rw-r--r--common/str.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/common/str.cpp b/common/str.cpp
index faf84d722f..ad02bfdaf8 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -665,6 +665,18 @@ String lastPathComponent(const String &path, const char sep) {
return String(first, last);
}
+String String::stringByAppendingPathComponent(String component, char sep) const {
+ if (lastChar() == sep && component.firstChar() == sep) {
+ return String::format("%s%s", c_str(), component.c_str() + 1);
+ }
+
+ if (lastChar() == sep || component.firstChar() == sep) {
+ return String::format("%s%s", c_str(), component.c_str());
+ }
+
+ return String::format("%s%c%s", c_str(), sep, component.c_str());
+}
+
String normalizePath(const String &path, const char sep) {
if (path.empty())
return path;