aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/utils/path_util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/wintermute/utils/path_util.cpp')
-rw-r--r--engines/wintermute/utils/path_util.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/engines/wintermute/utils/path_util.cpp b/engines/wintermute/utils/path_util.cpp
index db986061f8..60a07f0bf0 100644
--- a/engines/wintermute/utils/path_util.cpp
+++ b/engines/wintermute/utils/path_util.cpp
@@ -63,6 +63,10 @@ Common::String PathUtil::combine(const Common::String &path1, const Common::Stri
return newPath1 + newPath2;
}
+bool PathUtil::hasTrailingSlash(const Common::String &path) {
+ return (path.size() > 0 && path[path.size() - 1 ] == '/');
+}
+
//////////////////////////////////////////////////////////////////////////
Common::String PathUtil::getDirectoryName(const Common::String &path) {
Common::String newPath = unifySeparators(path);
@@ -74,10 +78,10 @@ Common::String PathUtil::getDirectoryName(const Common::String &path) {
Common::String PathUtil::getFileName(const Common::String &path) {
Common::String newPath = unifySeparators(path);
Common::String lastPart = Common::lastPathComponent(newPath, '/');
- if (lastPart[lastPart.size() - 1 ] != '/') {
- return lastPart;
+ if (hasTrailingSlash(newPath)) {
+ return Common::String("");
} else {
- return path;
+ return lastPart;
}
}