diff options
author | Einar Johan Trøan Sømåen | 2012-07-22 22:30:24 +0200 |
---|---|---|
committer | Einar Johan Trøan Sømåen | 2012-07-22 22:30:24 +0200 |
commit | 803c4215534bdbdc545c8aa32418444e27d607f5 (patch) | |
tree | eff457e9d01e1e767a861f627adaffc192bb1db7 | |
parent | 4c3421288d2d74396579f35b25a7b78e14afa7f4 (diff) | |
download | scummvm-rg350-803c4215534bdbdc545c8aa32418444e27d607f5.tar.gz scummvm-rg350-803c4215534bdbdc545c8aa32418444e27d607f5.tar.bz2 scummvm-rg350-803c4215534bdbdc545c8aa32418444e27d607f5.zip |
WINTERMUTE: Fix a few issues in PathUtil, mainly getFileNameWithoutExtension was off by one
-rw-r--r-- | engines/wintermute/utils/path_util.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/engines/wintermute/utils/path_util.cpp b/engines/wintermute/utils/path_util.cpp index 6b6b2d6b96..6812d824df 100644 --- a/engines/wintermute/utils/path_util.cpp +++ b/engines/wintermute/utils/path_util.cpp @@ -37,10 +37,11 @@ namespace WinterMute { AnsiString PathUtil::unifySeparators(const AnsiString &path) {
AnsiString newPath = path;
- AnsiString::iterator it;
- for (it = newPath.begin(); it != newPath.end(); it++) {
- if (*it == '\\') *it = '/';
+ for (uint32 i = 0; i < newPath.size(); i++) {
+ if (newPath[i] == '\\')
+ newPath.setChar('/', i);
}
+
return newPath;
}
@@ -78,7 +79,7 @@ AnsiString PathUtil::getFileName(const AnsiString &path) { AnsiString newPath = unifySeparators(path);
//size_t pos = newPath.find_last_of(L'/'); TODO REMOVE.
- Common::String lastPart = Common::lastPathComponent(path, '/');
+ Common::String lastPart = Common::lastPathComponent(newPath, '/');
if (lastPart[lastPart.size() - 1 ] != '/')
return lastPart;
else
@@ -93,9 +94,12 @@ AnsiString PathUtil::getFileNameWithoutExtension(const AnsiString &path) { //size_t pos = fileName.find_last_of('.'); //TODO REMOVE!
// TODO: Prettify this.
- Common::String extension = Common::lastPathComponent(path, '.');
- Common::String filename = Common::String(path.c_str(), path.size() - extension.size());
- return filename;
+ AnsiString extension = Common::lastPathComponent(fileName, '.');
+ for (int i = 0; i < extension.size() + 1; i++) {
+ fileName.deleteLastChar();
+ }
+// Common::String filename = Common::String(fileName.c_str(), fileName.size() - extension.size() + 1);
+ return fileName;
//if (pos == AnsiString::npos) return fileName;
//else return fileName.substr(0, pos);
}
|