mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 21:59:17 +00:00
LAB: Add a workaround for DOS version using long filenames
This commit is contained in:
parent
5fb0787bd7
commit
78b9a903ad
@ -175,22 +175,50 @@ Common::String Resource::translateFileName(const Common::String filename) {
|
|||||||
upperFilename.deleteChar(0);
|
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;
|
fileNameStrFinal += upperFilename;
|
||||||
|
|
||||||
return fileNameStrFinal;
|
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();
|
Common::File *dataFile = new Common::File();
|
||||||
dataFile->open(translateFileName(fileName));
|
dataFile->open(translateFileName(filename));
|
||||||
if (!dataFile->isOpen())
|
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) {
|
if (fileHeader > 0) {
|
||||||
uint32 headerTag = dataFile->readUint32BE();
|
uint32 headerTag = dataFile->readUint32BE();
|
||||||
if (headerTag != fileHeader) {
|
if (headerTag != fileHeader) {
|
||||||
dataFile->close();
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ public:
|
|||||||
Resource(LabEngine *vm);
|
Resource(LabEngine *vm);
|
||||||
~Resource() {}
|
~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);
|
void readRoomData(const Common::String fileName);
|
||||||
InventoryData *readInventory(const Common::String fileName);
|
InventoryData *readInventory(const Common::String fileName);
|
||||||
void readViews(uint16 roomNum);
|
void readViews(uint16 roomNum);
|
||||||
|
Loading…
Reference in New Issue
Block a user