Skip to content

Commit

Permalink
tweak: remove global exePath & titlePath
Browse files Browse the repository at this point in the history
  • Loading branch information
ToeKneeRED committed Sep 9, 2024
1 parent 50488e3 commit 0f9c6ad
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions Code/immersive_launcher/oobe/PathArgument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

#include <filesystem>

std::wstring g_titlePath;
std::wstring g_exePath;

namespace oobe
{
using namespace TiltedPhoques;
Expand All @@ -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(*"\\"))
Expand All @@ -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";
Expand All @@ -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<wchar_t>(HKEY_CURRENT_USER, kTiltedRegistryPath, L"TitlePath", g_titlePath) && Registry::WriteString<wchar_t>(HKEY_CURRENT_USER, kTiltedRegistryPath, L"TitleExe", g_exePath);
const bool result = Registry::WriteString<wchar_t>(HKEY_CURRENT_USER, kTiltedRegistryPath, L"TitlePath", titlePath) && Registry::WriteString<wchar_t>(HKEY_CURRENT_USER, kTiltedRegistryPath, L"TitleExe", exePath);

if (!result)
{
Expand Down

0 comments on commit 0f9c6ad

Please sign in to comment.