diff options
Diffstat (limited to 'src/utils/stringutils.cpp')
-rw-r--r-- | src/utils/stringutils.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 3af63f96e..99160905d 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -338,10 +338,11 @@ std::string getFileName(const std::string &path) { size_t pos1 = path.rfind('/'); const size_t pos2 = path.rfind('\\'); - if (pos1 == std::string::npos) - pos1 = pos2; - else if (pos2 != std::string::npos && pos2 > pos1) + if (pos1 == std::string::npos || + (pos2 != std::string::npos && pos2 > pos1)) + { pos1 = pos2; + } if (pos1 == std::string::npos) return path; @@ -352,10 +353,11 @@ std::string getFileDir(const std::string &path) { size_t pos1 = path.rfind('/'); const size_t pos2 = path.rfind('\\'); - if (pos1 == std::string::npos) - pos1 = pos2; - else if (pos2 != std::string::npos && pos2 > pos1) + if (pos1 == std::string::npos || + (pos2 != std::string::npos && pos2 > pos1)) + { pos1 = pos2; + } if (pos1 == std::string::npos) return path; |