[Scummvm-git-logs] scummvm master -> cc76cd7ae9402a34c88f6b6a33c77aa26f4e143c

OMGPizzaGuy noreply at scummvm.org
Sun Dec 10 23:28:18 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
cc76cd7ae9 ULTIMA8: Remove unneeded uppercase handling in FileSystem class


Commit: cc76cd7ae9402a34c88f6b6a33c77aa26f4e143c
    https://github.com/scummvm/scummvm/commit/cc76cd7ae9402a34c88f6b6a33c77aa26f4e143c
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-12-10T17:28:02-06:00

Commit Message:
ULTIMA8: Remove unneeded uppercase handling in FileSystem class

Changed paths:
    engines/ultima/ultima8/filesys/file_system.cpp
    engines/ultima/ultima8/filesys/file_system.h


diff --git a/engines/ultima/ultima8/filesys/file_system.cpp b/engines/ultima/ultima8/filesys/file_system.cpp
index a7b662c16cd..b59e2f53d00 100644
--- a/engines/ultima/ultima8/filesys/file_system.cpp
+++ b/engines/ultima/ultima8/filesys/file_system.cpp
@@ -31,76 +31,28 @@ using Std::string;
 FileSystem *FileSystem::_fileSystem = nullptr;
 
 FileSystem::FileSystem() {
-	debugN(MM_INFO, "Creating FileSystem...\n");
-
 	_fileSystem = this;
 }
 
 FileSystem::~FileSystem() {
-	debugN(MM_INFO, "Destroying FileSystem...\n");
-
 	_fileSystem = nullptr;
 }
 
 
 // Open a streaming file as readable. Streamed (0 on failure)
 Common::SeekableReadStream *FileSystem::ReadFile(const string &vfn) {
-	Common::SeekableReadStream *readStream;
-	if (!rawOpen(readStream, vfn)) {
-		// Some games have some files in a "data" subdir.
-		string altpath = string::format("data/%s", vfn.c_str());
-		if (!rawOpen(readStream, altpath)) {
-			return nullptr;
-		}
-	}
-
-	return readStream;
-}
+	Common::File *f = new Common::File();
+	Common::Path path(vfn);
+	if (f->open(path))
+		return f;
 
-bool FileSystem::rawOpen(Common::SeekableReadStream *&in, const string &fname) {
-	string name = fname;
-	Common::File *f;
+	// Some games have some files in a "data" subdir.
+	Common::Path altpath = Common::Path("data").join(path);
+	if (f->open(altpath))
+		return f;
 
-	int uppercasecount = 0;
-	f = new Common::File();
-	do {
-		if (f->open(name)) {
-			in = f;
-			return true;
-		}
-	} while (base_to_uppercase(name, ++uppercasecount));
-
-	// file not found
 	delete f;
-	return false;
-}
-
-
-/*
- *  Convert just the last 'count' parts of a filename to uppercase.
- *  returns false if there are less than 'count' parts
- */
-
-bool FileSystem::base_to_uppercase(string &str, int count) {
-	if (count <= 0) return true;
-
-	int todo = count;
-	// Go backwards.
-	string::reverse_iterator X;
-	for (X = str.rbegin(); X != str.rend(); ++X) {
-		// Stop at separator.
-		if (*X == '/' || *X == '\\' || *X == ':')
-			todo--;
-		if (todo <= 0)
-			break;
-
-		*X = static_cast<char>(toupper(*X));
-	}
-	if (X == str.rend())
-		todo--; // start of pathname counts as separator too
-
-	// false if it didn't reach 'count' parts
-	return (todo <= 0);
+	return nullptr;
 }
 
 } // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/filesys/file_system.h b/engines/ultima/ultima8/filesys/file_system.h
index 719ed659c06..b2b7d12f6ad 100644
--- a/engines/ultima/ultima8/filesys/file_system.h
+++ b/engines/ultima/ultima8/filesys/file_system.h
@@ -43,16 +43,7 @@ public:
 	Common::SeekableReadStream *ReadFile(const Std::string &vfn);
 
 private:
-	static bool base_to_uppercase(Std::string &str, int count);
-
 	static FileSystem *_fileSystem;
-
-	/**
-	 *	Open a file for reading,
-	 *	Output: false if couldn't open.
-	 */
-	bool rawOpen(Common::SeekableReadStream *&in, const Std::string &fname);
-
 };
 
 } // End of namespace Ultima8




More information about the Scummvm-git-logs mailing list