mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-01 07:46:11 +00:00
DIRECTOR: Search for D4 Mac file extensions
This commit is contained in:
parent
9c537a8744
commit
e74c53054b
@ -375,6 +375,8 @@ Common::String pathMakeRelative(Common::String path, bool recursive, bool addext
|
||||
if (!opened && recursive) {
|
||||
// Hmmm. We couldn't find the path as is.
|
||||
// Let's try to translate file path into 8.3 format
|
||||
Common::String addedexts;
|
||||
|
||||
if (g_director->getPlatform() == Common::kPlatformWindows && g_director->getVersion() < 5) {
|
||||
convPath.clear();
|
||||
const char *ptr = initialPath.c_str();
|
||||
@ -397,24 +399,15 @@ Common::String pathMakeRelative(Common::String path, bool recursive, bool addext
|
||||
ptr++;
|
||||
}
|
||||
|
||||
const char *exts[] = { ".MMM", ".DIR", ".DXR", 0 };
|
||||
for (int i = 0; exts[i] && addexts; ++i) {
|
||||
Common::String newpath = convPath +
|
||||
(strcmp(exts[i], ".MMM") == 0 ? convertMacFilename(component.c_str()) : component.c_str()) + exts[i];
|
||||
if (addexts)
|
||||
addedexts = testExtensions(component, initialPath, convPath);
|
||||
} else {
|
||||
if (addexts)
|
||||
addedexts = testExtensions(initialPath, initialPath, convPath);
|
||||
}
|
||||
|
||||
debug(2, "pathMakeRelative(): s6 %s -> try %s", initialPath.c_str(), newpath.c_str());
|
||||
|
||||
Common::String res = pathMakeRelative(newpath, false, false);
|
||||
|
||||
if (testPath(res))
|
||||
return res;
|
||||
}
|
||||
} else if (g_director->getPlatform() == Common::kPlatformMacintosh && addexts) {
|
||||
// Try adding an extension D4 Mac movies
|
||||
Common::String res = pathMakeRelative(convPath + ".Dir", false, false);
|
||||
|
||||
if (testPath(res))
|
||||
return res;
|
||||
if (!addedexts.empty()) {
|
||||
return addedexts;
|
||||
}
|
||||
|
||||
return initialPath; // Anyway nothing good is happening
|
||||
@ -426,6 +419,21 @@ Common::String pathMakeRelative(Common::String path, bool recursive, bool addext
|
||||
return initialPath;
|
||||
}
|
||||
|
||||
Common::String testExtensions(Common::String component, Common::String initialPath, Common::String convPath) {
|
||||
const char *exts[] = { ".MMM", ".DIR", ".Dir", ".DXR", ".Dxr", 0 };
|
||||
for (int i = 0; exts[i]; ++i) {
|
||||
Common::String newpath = convPath + (strcmp(exts[i], ".MMM") == 0 ? convertMacFilename(component.c_str()) : component.c_str()) + exts[i];
|
||||
|
||||
debug(2, "pathMakeRelative(): s6 %s -> try %s", initialPath.c_str(), newpath.c_str());
|
||||
Common::String res = pathMakeRelative(newpath, false, false);
|
||||
|
||||
if (testPath(res))
|
||||
return res;
|
||||
}
|
||||
|
||||
return Common::String();
|
||||
}
|
||||
|
||||
Common::String getFileName(Common::String path) {
|
||||
while (path.contains('/')) {
|
||||
int pos = path.find('/');
|
||||
|
@ -42,6 +42,8 @@ bool testPath(Common::String &path);
|
||||
|
||||
Common::String pathMakeRelative(Common::String path, bool recursive = true, bool addexts = true);
|
||||
|
||||
Common::String testExtensions(Common::String component, Common::String initialPath, Common::String convPath);
|
||||
|
||||
Common::String getFileName(Common::String path);
|
||||
|
||||
Common::String stripMacPath(const char *name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user