@@ -65,19 +65,34 @@ int main(int argc, char *argv[])
65
65
#define MAX_PATH_LEN 256
66
66
char currentWorkingDir[MAX_PATH_LEN];
67
67
char envVarString[2 * MAX_PATH_LEN];
68
- GetCurrentDirectory (MAX_PATH_LEN - 1 , currentWorkingDir);
68
+ DWORD bufferSize = MAX_PATH_LEN;
69
+
70
+ QueryFullProcessImageName (GetCurrentProcess (), 0 , currentWorkingDir, &bufferSize);
71
+ // Strip the exe filenameb (from last backslash onwards), leave just the path
72
+ char *probeString = strrchr (currentWorkingDir, ' \\ ' );
73
+ if (probeString) *probeString = ' \0 ' ; // currentWorkingDir now contains the path we need
74
+
75
+ // Prepend system PATH env variable with our own executable's path
76
+ char finalPath[16 * MAX_PATH_LEN];
77
+ char *systemPath = SDL_getenv (" PATH" );
78
+ strcpy (finalPath, currentWorkingDir);
79
+ strcat (finalPath, " ;" );
80
+ strcat (finalPath, systemPath);
69
81
70
82
#define SETENVVAR (var, value ) do {\
71
83
sprintf (envVarString, " %s =%s " , (var), (value));\
72
84
SDL_putenv (envVarString);\
73
85
} while (0 );
74
86
75
87
SETENVVAR (" GNUSTEP_PATH_HANDLING" , " windows" );
88
+ SETENVVAR (" PATH" , finalPath);
76
89
SETENVVAR (" GNUSTEP_SYSTEM_ROOT" , currentWorkingDir);
77
90
SETENVVAR (" GNUSTEP_LOCAL_ROOT" , currentWorkingDir);
78
91
SETENVVAR (" GNUSTEP_NETWORK_ROOT" , currentWorkingDir);
79
92
SETENVVAR (" GNUSTEP_USERS_ROOT" , currentWorkingDir);
80
93
SETENVVAR (" HOMEPATH" , currentWorkingDir);
94
+
95
+ SetCurrentDirectory (currentWorkingDir);
81
96
82
97
/* Windows amibtiously starts apps with the C library locale set to the
83
98
system locale rather than the "C" locale as per spec. Fixing here so
0 commit comments