Improved the %ROM% and %INJECT% variable logic and added support for Windows

This commit is contained in:
Leon Styhre 2024-06-03 20:45:26 +02:00
parent ca65fcbe8c
commit bdebe0133c

View file

@ -1574,19 +1574,30 @@ void FileData::launchGame()
injectFile = Utils::String::replace(injectFile, "\\", "/"); injectFile = Utils::String::replace(injectFile, "\\", "/");
injectFile = Utils::String::replace(injectFile, "%BASENAME%", injectFile = Utils::String::replace(injectFile, "%BASENAME%",
Utils::String::replace(baseName, "\"", "")); Utils::String::replace(baseName, "\"", ""));
if (injectFile.size() < 3 || !(injectFile[1] == ':' && injectFile[2] == '/')) if (injectFile == "%ROM%") {
injectFile = injectFile = Utils::String::replace(injectFile, "%ROM%",
Utils::FileSystem::getParent(Utils::String::replace(romPath, "\"", "")) + "/" + Utils::String::replace(romRaw, "\"", ""));
injectFile; }
else {
if (injectFile.size() < 3 || !(injectFile[1] == ':' && injectFile[2] == '/'))
injectFile =
Utils::FileSystem::getParent(Utils::String::replace(romPath, "\"", "")) +
"/" + injectFile;
}
injectFile = Utils::String::replace(injectFile, "/", "\\"); injectFile = Utils::String::replace(injectFile, "/", "\\");
#else #else
injectFile = Utils::String::replace(injectFile, "%BASENAME%", injectFile = Utils::String::replace(injectFile, "%BASENAME%",
Utils::String::replace(baseName, "\\", "")); Utils::String::replace(baseName, "\\", ""));
injectFile = Utils::String::replace(injectFile, "%ROM%", romRaw); if (injectFile == "%ROM%") {
if (injectFile.front() != '/') injectFile = Utils::String::replace(injectFile, "%ROM%",
injectFile = Utils::String::replace(romRaw, "\\", ""));
Utils::FileSystem::getParent(Utils::String::replace(romPath, "\\", "")) + "/" + }
injectFile; else {
if (injectFile.front() != '/')
injectFile =
Utils::FileSystem::getParent(Utils::String::replace(romPath, "\\", "")) +
"/" + injectFile;
}
#endif #endif
if (Utils::FileSystem::isRegularFile(injectFile) || if (Utils::FileSystem::isRegularFile(injectFile) ||
Utils::FileSystem::isSymlink(injectFile)) { Utils::FileSystem::isSymlink(injectFile)) {