summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/stringutils.cpp10
-rw-r--r--src/utils/stringutils.h2
2 files changed, 12 insertions, 0 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index dffec3f0c..953cbf58a 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -305,6 +305,16 @@ std::string getFileName(std::string path)
return path.substr(pos + 1);
}
+std::string getFileDir(std::string path)
+{
+ size_t pos = path.rfind("/");
+ if (pos == std::string::npos)
+ pos = path.rfind("\\");
+ if (pos == std::string::npos)
+ return "";
+ return path.substr(0, pos);
+}
+
std::string& replaceAll(std::string& context, const std::string& from,
const std::string& to)
{
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index 796df92c5..140baf944 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -149,6 +149,8 @@ void getSafeUtf8String(std::string text, char *buf);
std::string getFileName(std::string path);
+std::string getFileDir(std::string path);
+
std::string& replaceAll(std::string& context, const std::string& from,
const std::string& to);