diff options
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/stringutils.cpp | 10 | ||||
-rw-r--r-- | src/utils/stringutils.h | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index d914efe30..835f9ce00 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -387,3 +387,13 @@ std::list<int> splitToIntList(const std::string &text, char separator) return tokens; } + +std::string combineDye(std::string file, std::string dye) +{ + if (dye.empty()) + return file; + size_t pos = file.find_last_of("|"); + if (pos != std::string::npos) + return file.substr(0, pos) + "|" + dye; + return file + "|" + dye; +} diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h index ab16bb64b..52b47e6a2 100644 --- a/src/utils/stringutils.h +++ b/src/utils/stringutils.h @@ -170,4 +170,6 @@ std::set<int> splitToIntSet(const std::string &text, char separator); std::list<int> splitToIntList(const std::string &text, char separator); +std::string combineDye(std::string file, std::string dye); + #endif // UTILS_STRINGUTILS_H |