Lines 286-291
Link Here
|
286 |
|
286 |
|
287 |
void adjustSearchPath( _TCHAR* vmLib ){ |
287 |
void adjustSearchPath( _TCHAR* vmLib ){ |
288 |
_TCHAR ** paths; |
288 |
_TCHAR ** paths; |
|
|
289 |
_TCHAR* cwd = NULL; |
289 |
_TCHAR * path = NULL, *newPath = NULL; |
290 |
_TCHAR * path = NULL, *newPath = NULL; |
290 |
_TCHAR * c; |
291 |
_TCHAR * c; |
291 |
int i, length; |
292 |
int i, length; |
Lines 293-304
Link Here
|
293 |
|
294 |
|
294 |
paths = getVMLibrarySearchPath(vmLib); |
295 |
paths = getVMLibrarySearchPath(vmLib); |
295 |
|
296 |
|
|
|
297 |
/* bug 325902 - add current working dir to the end of the search path */ |
298 |
length = GetCurrentDirectory(0, NULL); |
299 |
cwd = malloc((length + 1)* sizeof(_TCHAR)); |
300 |
GetCurrentDirectory(length, cwd); |
301 |
cwd[length - 1] = pathSeparator; |
302 |
cwd[length] = 0; |
303 |
|
296 |
/* first call to GetEnvironmentVariable tells us how big to make the buffer */ |
304 |
/* first call to GetEnvironmentVariable tells us how big to make the buffer */ |
297 |
length = GetEnvironmentVariable(_T_ECLIPSE("PATH"), path, 0); |
305 |
length = GetEnvironmentVariable(_T_ECLIPSE("PATH"), path, 0); |
298 |
if (length > 0) { |
306 |
if (length > 0) { |
|
|
307 |
_TCHAR* current [] = { cwd, NULL }; |
299 |
path = malloc(length * sizeof(_TCHAR)); |
308 |
path = malloc(length * sizeof(_TCHAR)); |
300 |
GetEnvironmentVariable(_T_ECLIPSE("PATH"), path, length); |
309 |
GetEnvironmentVariable(_T_ECLIPSE("PATH"), path, length); |
301 |
needAdjust = !containsPaths(path, paths); |
310 |
needAdjust = !containsPaths(path, paths) || !containsPaths(path, current); |
302 |
freePath = 1; |
311 |
freePath = 1; |
303 |
} else { |
312 |
} else { |
304 |
path = _T_ECLIPSE(""); |
313 |
path = _T_ECLIPSE(""); |
Lines 308-315
Link Here
|
308 |
|
317 |
|
309 |
if (needAdjust) { |
318 |
if (needAdjust) { |
310 |
c = concatStrings(paths); |
319 |
c = concatStrings(paths); |
311 |
newPath = malloc((_tcslen(c) + length + 1) * sizeof(_TCHAR)); |
320 |
newPath = malloc((_tcslen(c) + length + 1 + _tcslen(cwd) + 1) * sizeof(_TCHAR)); |
312 |
_stprintf(newPath, _T_ECLIPSE("%s%s"), c, path); |
321 |
_stprintf(newPath, _T_ECLIPSE("%s%s%c%s"), c, path, pathSeparator, cwd); |
313 |
SetEnvironmentVariable( _T_ECLIPSE("PATH"), newPath); |
322 |
SetEnvironmentVariable( _T_ECLIPSE("PATH"), newPath); |
314 |
free(c); |
323 |
free(c); |
315 |
free(newPath); |
324 |
free(newPath); |
Lines 318-323
Link Here
|
318 |
for (i = 0; paths[i] != NULL; i++) |
327 |
for (i = 0; paths[i] != NULL; i++) |
319 |
free(paths[i]); |
328 |
free(paths[i]); |
320 |
free(paths); |
329 |
free(paths); |
|
|
330 |
free(cwd); |
321 |
if (freePath) |
331 |
if (freePath) |
322 |
free(path); |
332 |
free(path); |
323 |
} |
333 |
} |