Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Commit

Permalink
Update launcher.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
garyttierney authored Mar 31, 2024
1 parent 5d38623 commit 8eac2f3
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions launcher/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,16 @@ void set_env_var(const std::wstring& name, const std::wstring& value)

fs::path get_launcher_directory()
{
size_t buffer_size = GetModuleFileNameW(nullptr, nullptr, 0);
auto* buffer = new wchar_t[buffer_size + 1];
wchar_t buffer[MAX_PATH];
size_t buffer_size = GetModuleFileNameW(nullptr, &buffer[0], NAX_PATH);

fs::path path = fs::current_path();

if (buffer_size > 0) {
size_t len = GetModuleFileNameW(nullptr, buffer, buffer_size + 1);
fs::path launcher_path(std::wstring_view { buffer, len });

fs::path launcher_path(std::wstring_view { &buffer[0], buffer_size });
path = launcher_path.parent_path();
}

delete buffer;

return path;
}

Expand Down Expand Up @@ -245,4 +241,4 @@ int main()
CloseHandle(pi.hThread);

return status;
}
}

0 comments on commit 8eac2f3

Please sign in to comment.