From f4e387595263a3e34193053c3368ad2a0ed9c430 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Fri, 1 Jul 2022 16:42:21 +0200 Subject: [PATCH] (Windows) Fixed an issue where the emulator binary path would sometimes not get escaped correctly in es_log.txt on game launch. Also fixed some other path escape inconsistencies. --- es-app/src/FileData.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 41b4d156c..8dc6b2638 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -1027,9 +1027,11 @@ void FileData::launchGame() } #if defined(_WIN64) else { - LOG(LogDebug) << "FileData::launchGame(): Found emulator binary " - << Utils::String::replace( - Utils::String::replace(binaryPath, "%ESPATH%", esPath), "/", "\\"); + std::string binaryLogPath {Utils::String::replace( + Utils::String::replace(binaryPath, "%ESPATH%", esPath), "/", "\\")}; + if (binaryLogPath.front() != '\"' && binaryLogPath.back() != '\"') + binaryLogPath = "\"" + binaryLogPath + "\""; + LOG(LogDebug) << "FileData::launchGame(): Found emulator binary " << binaryLogPath; #else else if (!isShortcut) { LOG(LogDebug) << "FileData::launchGame(): Found emulator binary \"" @@ -1714,9 +1716,10 @@ const std::string FileData::findEmulatorPath(std::string& command) if (pathStatus == ERROR_SUCCESS) { if (Utils::FileSystem::isRegularFile(registryPath) || Utils::FileSystem::isSymlink(registryPath)) { - command.replace(startPos, endPos - startPos + 1, registryPath); + exePath = Utils::FileSystem::getEscapedPath(registryPath); + command.replace(startPos, endPos - startPos + 1, exePath); RegCloseKey(registryKey); - return registryPath; + return exePath; } } RegCloseKey(registryKey); @@ -1777,9 +1780,10 @@ const std::string FileData::findEmulatorPath(std::string& command) // so check for that as well. if (pathStatus == ERROR_SUCCESS) { if (Utils::FileSystem::isRegularFile(path) || Utils::FileSystem::isSymlink(path)) { - command.replace(startPos, endPos - startPos + 1, path); + exePath = Utils::FileSystem::getEscapedPath(path); + command.replace(startPos, endPos - startPos + 1, exePath); RegCloseKey(registryKey); - return path; + return exePath; } } RegCloseKey(registryKey); @@ -1807,6 +1811,7 @@ const std::string FileData::findEmulatorPath(std::string& command) } if (exePath != "") { exePath += "\\" + path; + exePath = Utils::FileSystem::getEscapedPath(exePath); command.replace(startPos, endPos - startPos + 1, exePath); return exePath; } @@ -1842,9 +1847,9 @@ const std::string FileData::findEmulatorPath(std::string& command) } if (Utils::FileSystem::isRegularFile(path) || Utils::FileSystem::isSymlink(path)) { - path = Utils::FileSystem::getEscapedPath(path); - command.replace(startPos, endPos - startPos + 1, path); - return path; + exePath = Utils::FileSystem::getEscapedPath(path); + command.replace(startPos, endPos - startPos + 1, exePath); + return exePath; } }