[Scummvm-git-logs] scummvm master -> 7b10664c3cf105509a65dcb323d4e9a263853e95
aquadran
noreply at scummvm.org
Tue Sep 16 13:12:51 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
7b10664c3c WINTERMUTE: Synced with original code
Commit: 7b10664c3cf105509a65dcb323d4e9a263853e95
https://github.com/scummvm/scummvm/commit/7b10664c3cf105509a65dcb323d4e9a263853e95
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2025-09-16T15:12:44+02:00
Commit Message:
WINTERMUTE: Synced with original code
Changed paths:
engines/wintermute/base/base_sprite.cpp
engines/wintermute/utils/path_util.cpp
diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp
index f4c8e3f7c90..9f7260bc0d7 100644
--- a/engines/wintermute/base/base_sprite.cpp
+++ b/engines/wintermute/base/base_sprite.cpp
@@ -139,7 +139,7 @@ bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType c
AnsiString ext = PathUtil::getExtension(filename);
ext.toLowercase();
filePrefix.toLowercase();
- if (filePrefix.hasPrefix("savegame:") || (ext == "bmp") || (ext == "tga") || (ext == "png") || (ext == "jpg")) {
+ if (filePrefix.hasPrefix("savegame:") || (ext == ".bmp") || (ext == ".tga") || (ext == ".png") || (ext == ".jpg")) {
BaseFrame *frame = new BaseFrame(_game);
BaseSubFrame *subframe = new BaseSubFrame(_game);
subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true);
diff --git a/engines/wintermute/utils/path_util.cpp b/engines/wintermute/utils/path_util.cpp
index 459007152c8..c673df9954d 100644
--- a/engines/wintermute/utils/path_util.cpp
+++ b/engines/wintermute/utils/path_util.cpp
@@ -62,47 +62,59 @@ 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);
- Common::String filename = getFileName(path);
- if (hasTrailingSlash(newPath)) {
- return path;
+
+ size_t pos = newPath.findLastOf('/');
+
+ if (pos == AnsiString::npos) {
+ return "";
} else {
- return Common::String(path.c_str(), path.size() - filename.size());
+ return newPath.substr(0, pos + 1);
}
}
//////////////////////////////////////////////////////////////////////////
Common::String PathUtil::getFileName(const Common::String &path) {
Common::String newPath = unifySeparators(path);
- Common::String lastPart = Common::lastPathComponent(newPath, '/');
- if (hasTrailingSlash(newPath)) {
- return Common::String("");
+
+ size_t pos = newPath.findLastOf('/');
+
+ if (pos == Common::String::npos) {
+ return path;
} else {
- return lastPart;
+ return newPath.substr(pos + 1);
}
}
//////////////////////////////////////////////////////////////////////////
Common::String PathUtil::getFileNameWithoutExtension(const Common::String &path) {
Common::String fileName = getFileName(path);
- // TODO: Prettify this.
- Common::String extension = Common::lastPathComponent(fileName, '.');
- for (uint32 i = 0; i < extension.size() + 1; i++) {
- fileName.deleteLastChar();
+
+ size_t pos = fileName.findLastOf('.');
+
+ if (pos == Common::String::npos) {
+ return fileName;
+ } else {
+ return fileName.substr(0, pos);
}
- return fileName;
}
+
//////////////////////////////////////////////////////////////////////////
Common::String PathUtil::getExtension(const Common::String &path) {
Common::String fileName = getFileName(path);
- return Common::lastPathComponent(path, '.');
+
+ size_t pos = fileName.findLastOf('.');
+
+ if (pos == Common::String::npos) {
+ return "";
+ } else {
+ return fileName.substr(pos);
+ }
}
+
} // End of namespace Wintermute
More information about the Scummvm-git-logs
mailing list