Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions nsis/winpath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,21 @@
// This will start a Windows command line with PATH extended by
// the location of the winpath executable.

#include <filesystem> // std::filesystem::path
#include <process.h> // _spawnvp
#include <stdlib.h> // _putenv_s
#include <string.h> // strcpy, strcat

static char path[4096];
#include <cstdlib> // _putenv_s, getenv
#include <string> // std::string

int main(int argc, char *argv[]) {
if (argc > 1) {
char *dir = argv[0];
char *last = strrchr(dir, '\\');
if (last != nullptr) {
*last = '\0';
}
strcpy(path, dir);
strcat(path, ";");
strcat(path, getenv("PATH"));
_putenv_s("PATH", path);
_spawnvp(_P_WAIT, argv[1], argv + 1);
std::filesystem::path exe_path(argv[0]);
std::string dir = exe_path.parent_path().string();

const char *env_path = getenv("PATH");
std::string new_path = dir + ";" + (env_path ? env_path : "");

_putenv_s("PATH", new_path.c_str());
return _spawnvp(_P_WAIT, argv[1], argv + 1);
//~ _spawnvp(_P_OVERLAY, argv[1], argv + 1);
}
return 0;
Expand Down