diff options
Diffstat (limited to 'src/utils/stringutils.cpp')
-rw-r--r-- | src/utils/stringutils.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 45be9ef9c..3af63f96e 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -1157,6 +1157,37 @@ std::string urlJoin(std::string str1, } } +size_t rfindSepatator(const std::string &str1) +{ + const size_t idx1 = str1.rfind('/'); + const size_t idx2 = str1.rfind('\\'); + if (idx1 != std::string::npos) + { // idx1 + if (idx2 != std::string::npos) + { // idx1, idx2 + if (idx1 >= idx2) + return idx1; + else + return idx2; + } + else + { // idx1, not idx2 + return idx1; + } + } + else + { // not idx1 + if (idx2 != std::string::npos) + { // not idx1, idx2 + return idx2; + } + else + { // not idx1, not idx2 + return std::string::npos; + } + } +} + #ifndef DYECMD void replaceItemLinks(std::string &msg) { |