[Scummvm-cvs-logs] scummvm master -> 78b9a903add0431893c92e5e4c8f01b761a48277

Strangerke Strangerke at scummvm.org
Sun Jan 24 13:42:18 CET 2016


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:
78b9a903ad LAB: Add a workaround for DOS version using long filenames


Commit: 78b9a903add0431893c92e5e4c8f01b761a48277
    https://github.com/scummvm/scummvm/commit/78b9a903add0431893c92e5e4c8f01b761a48277
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-01-24T13:34:37+01:00

Commit Message:
LAB: Add a workaround for DOS version using long filenames

Changed paths:
    engines/lab/resource.cpp
    engines/lab/resource.h



diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index f16fd53..096d293 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -175,22 +175,50 @@ Common::String Resource::translateFileName(const Common::String filename) {
 		upperFilename.deleteChar(0);
 	}
 
+	if (_vm->getPlatform() == Common::kPlatformDOS) {
+		// Some script of the DOS version uses names used in the Amiga (and Windows) version,
+		// which isn't limited to 8.3 characters. We need to parse upperFilename to detect
+		// the filename, and fix it if required so it matches a DOS filename.
+		while (upperFilename.contains('/') && upperFilename.size()) {
+			fileNameStrFinal += upperFilename[0];
+			upperFilename.deleteChar(0);
+		}
+
+		for (int i = 0; (i < 8) && upperFilename.size() && (upperFilename[0] != '.'); i++) {
+			fileNameStrFinal += upperFilename[0];
+			upperFilename.deleteChar(0);
+		}
+
+		// Remove the extra character in the filename
+		while (upperFilename.size() && (upperFilename[0] != '.'))
+			upperFilename.deleteChar(0);
+
+		// copy max 4 characters for the extension ('.foo')
+		for (int i = 0; (i < 4) && upperFilename.size(); i++) {
+			fileNameStrFinal += upperFilename[0];
+			upperFilename.deleteChar(0);
+		}
+
+		// Skip the extra characters of the extension
+		upperFilename.clear();
+	}
+
 	fileNameStrFinal += upperFilename;
 
 	return fileNameStrFinal;
 }
 
-Common::File *Resource::openDataFile(const Common::String fileName, uint32 fileHeader) {
+Common::File *Resource::openDataFile(const Common::String filename, uint32 fileHeader) {
 	Common::File *dataFile = new Common::File();
-	dataFile->open(translateFileName(fileName));
+	dataFile->open(translateFileName(filename));
 	if (!dataFile->isOpen())
-		error("openDataFile: Couldn't open %s (%s)", translateFileName(fileName).c_str(), fileName.c_str());
+		error("openDataFile: Couldn't open %s (%s)", translateFileName(filename).c_str(), filename.c_str());
 
 	if (fileHeader > 0) {
 		uint32 headerTag = dataFile->readUint32BE();
 		if (headerTag != fileHeader) {
 			dataFile->close();
-			error("openDataFile: Unexpected header in %s (%s) - expected: %d, got: %d", translateFileName(fileName).c_str(), fileName.c_str(), fileHeader, headerTag);
+			error("openDataFile: Unexpected header in %s (%s) - expected: %d, got: %d", translateFileName(filename).c_str(), filename.c_str(), fileHeader, headerTag);
 		}
 	}
 
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 307eac3..9a242b1 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -97,7 +97,7 @@ public:
 	Resource(LabEngine *vm);
 	~Resource() {}
 
-	Common::File *openDataFile(const Common::String fileName, uint32 fileHeader = 0);
+	Common::File *openDataFile(const Common::String filename, uint32 fileHeader = 0);
 	void readRoomData(const Common::String fileName);
 	InventoryData *readInventory(const Common::String fileName);
 	void readViews(uint16 roomNum);






More information about the Scummvm-git-logs mailing list