summaryrefslogtreecommitdiff
path: root/src/utils/stringutils.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2019-03-07 02:11:23 +0300
committerAndrei Karas <akaras@inbox.ru>2019-03-07 04:43:13 +0300
commit6b7551264a65f4e9d330a79a9a917a3febd2de44 (patch)
treeee2a50dbb4c61a2438b285cf6970a50fc811b911 /src/utils/stringutils.cpp
parentd459087cfef054b9172836dde6c2f433d2aecbc7 (diff)
downloadmv-6b7551264a65f4e9d330a79a9a917a3febd2de44.tar.gz
mv-6b7551264a65f4e9d330a79a9a917a3febd2de44.tar.bz2
mv-6b7551264a65f4e9d330a79a9a917a3febd2de44.tar.xz
mv-6b7551264a65f4e9d330a79a9a917a3febd2de44.zip
Add function for find first right separator
Diffstat (limited to 'src/utils/stringutils.cpp')
-rw-r--r--src/utils/stringutils.cpp31
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)
{