From 0f9c6addc6ac0973b1b481f6e50d3cfd7a03cae8 Mon Sep 17 00:00:00 2001 From: Tony Date: Mon, 9 Sep 2024 16:14:59 -0400 Subject: [PATCH] tweak: remove global exePath & titlePath --- Code/immersive_launcher/oobe/PathArgument.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Code/immersive_launcher/oobe/PathArgument.cpp b/Code/immersive_launcher/oobe/PathArgument.cpp index 7b582b5c8..ac1b230c7 100644 --- a/Code/immersive_launcher/oobe/PathArgument.cpp +++ b/Code/immersive_launcher/oobe/PathArgument.cpp @@ -7,9 +7,6 @@ #include -std::wstring g_titlePath; -std::wstring g_exePath; - namespace oobe { using namespace TiltedPhoques; @@ -26,6 +23,7 @@ constexpr wchar_t kTiltedRegistryPath[] = LR"(Software\TiltedPhoques\TiltedEvolu bool ValidatePath(const std::wstring& acPath) { + const std::wstring titlePath = acPath.substr(0, acPath.find_last_of('\\')); std::wstring errorText{}; if (acPath.find_last_of('\\') == std::string::npos || acPath.ends_with(*"\\")) @@ -45,7 +43,8 @@ bool ValidatePath(const std::wstring& acPath) errorText += TARGET_NAME L".exe not found\n"; } - if (!std::filesystem::exists(g_exePath) || !std::filesystem::exists(g_titlePath)) + + if (!std::filesystem::exists(acPath) || !std::filesystem::exists(titlePath)) { SetLastError(ERROR_BAD_PATHNAME); errorText += L"Path does not exist\n"; @@ -63,16 +62,16 @@ bool ValidatePath(const std::wstring& acPath) bool PathArgument(const std::string& acPath) { - g_exePath = std::wstring(acPath.begin(), acPath.end()); - g_titlePath = g_exePath.substr(0, g_exePath.find_last_of('\\')); + const std::wstring exePath = std::wstring(acPath.begin(), acPath.end()); + const std::wstring titlePath = exePath.substr(0, exePath.find_last_of('\\')); - if (!ValidatePath(g_exePath)) + if (!ValidatePath(exePath)) { DIE_NOW(L"Failed to validate path") } // Write to registry so oobe::SelectInstall can handle the rest - bool result = Registry::WriteString(HKEY_CURRENT_USER, kTiltedRegistryPath, L"TitlePath", g_titlePath) && Registry::WriteString(HKEY_CURRENT_USER, kTiltedRegistryPath, L"TitleExe", g_exePath); + const bool result = Registry::WriteString(HKEY_CURRENT_USER, kTiltedRegistryPath, L"TitlePath", titlePath) && Registry::WriteString(HKEY_CURRENT_USER, kTiltedRegistryPath, L"TitleExe", exePath); if (!result) {