SLUDGE: Migrate engine to Path

This commit is contained in:
Le Philousophe 2023-09-17 18:23:45 +02:00 committed by Eugene Sandulenko
parent 98dc1933a5
commit 6ad766f8d8
6 changed files with 13 additions and 12 deletions

View File

@ -250,7 +250,7 @@ builtIn(fileExists) {
bool exist = false;
Common::File fd;
if (fd.open(aaaaa)) {
if (fd.open(Common::Path(aaaaa))) {
exist = true;
fd.close();
} else {
@ -884,7 +884,8 @@ builtIn(launch) {
return BR_CONTINUE;
}
Common::String gameDir = ConfMan.get("path");
// Convert game path to URL
Common::String gameDir = ConfMan.getPath("path").toString('/');
newText = gameDir + newText;
// local webpage?
@ -2386,7 +2387,7 @@ builtIn(_rem_launchWith) {
trimStack(fun->stack);
if (filename.hasSuffix(".exe")) {
const Common::FSNode gameDataDir(ConfMan.get("path"));
const Common::FSNode gameDataDir(ConfMan.getPath("path"));
Common::FSList files;
gameDataDir.getChildren(files, Common::FSNode::kListFilesOnly);

View File

@ -115,9 +115,9 @@ ADDetectedGame SludgeMetaEngineDetection::fallbackDetect(const FileMap &allFiles
if (file->isDirectory())
continue;
Common::String fileName = file->getName();
Common::Path fileName = file->getPathInArchive();
fileName.toLowercase();
if (!(fileName.hasSuffix(".slg") || fileName == "gamedata"))
if (!(fileName.baseName().hasSuffix(".slg") || fileName == "gamedata"))
continue;
Common::File f;
@ -141,7 +141,7 @@ ADDetectedGame SludgeMetaEngineDetection::fallbackDetect(const FileMap &allFiles
continue;
}
strncpy(s_fallbackFileNameBuffer, fileName.c_str(), 50);
strncpy(s_fallbackFileNameBuffer, fileName.toString('/').c_str(), 50);
s_fallbackFileNameBuffer[50] = '\0';
s_fallbackDesc.desc.filesDescriptions[0].fileName = s_fallbackFileNameBuffer;

View File

@ -223,7 +223,7 @@ void ResourceManager::dumpFile(int num, const char *pattern) {
return;
Common::DumpFile dumpFile;
dumpFile.open(Common::String("dumps/") + Common::String::format(pattern, num));
dumpFile.open(Common::Path("dumps/").appendComponent(Common::String::format(pattern, num)));
uint32 pos = _bigDataFile->pos();
_bigDataFile->seek(_startOfDataIndex + (num << 2), 0);

View File

@ -258,7 +258,7 @@ void FloorManager::dumpFloor(int fileNum) {
return;
Common::DumpFile dumpFile;
dumpFile.open(Common::String::format("dumps/floor%04d.flo", fileNum));
dumpFile.open(Common::Path(Common::String::format("dumps/floor%04d.flo", fileNum)));
for (int i = 0; i < _currentFloor->numPolygons; i++) {
int nV = _currentFloor->polygon[i].numVertices;

View File

@ -58,12 +58,12 @@ bool ImgLoader::loadImage(int num, const char *fname, Common::SeekableReadStream
if (dumpPng || (fname && num == -1)) {
// Debug code to output light map image
Common::DumpFile *outFile = new Common::DumpFile();
Common::String outName;
Common::Path outName;
if (dumpPng)
outName = Common::String::format("dumps/%s%04d.png", fname, num);
outName = Common::Path(Common::String::format("dumps/%s%04d.png", fname, num));
else
outName = Common::String::format("dumps/%s.png", fname);
outName = Common::Path(Common::String::format("dumps/%s.png", fname));
outFile->open(outName);
Image::writePNG(*outFile, *dest);

View File

@ -67,7 +67,7 @@ extern bool allowAnyFilename;
Common::File *openAndVerify(const Common::String &filename, char extra1, char extra2,
const char *er, int &fileVersion) {
Common::File *fp = new Common::File();
if (!fp->open(filename)) {
if (!fp->open(Common::Path(filename))) {
fatal("Can't open file", filename);
return NULL;
}