diff --git a/core/string.cpp b/core/string.cpp index 1014223..91352a3 100644 --- a/core/string.cpp +++ b/core/string.cpp @@ -1043,6 +1043,17 @@ void String::append_path(const String &path) { } } +void String::path_clean_end_slash() { + while (ends_with('/') || ends_with('\\')) { + pop_back(); + } +} +void String::path_ensure_end_slash() { + if (!(ends_with('/') || ends_with('\\'))) { + push_back(DEFAULT_DIRECTORY_SEPARATOR); + } +} + void String::to_html_special_chars() { replace("&", "&"); replace("\"", """); diff --git a/core/string.h b/core/string.h index edb6356..b3836cb 100644 --- a/core/string.h +++ b/core/string.h @@ -109,6 +109,8 @@ public: void append_path(const char* path); void append_path(const String &path); + void path_clean_end_slash(); + void path_ensure_end_slash(); void to_html_special_chars(); void from_html_special_chars();