Skip to content

Commit 00c6cdd

Browse files
committed
Merge 'fix-externals' into HEAD
2 parents 9610893 + 676b02a commit 00c6cdd

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

compat/mingw.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -998,14 +998,21 @@ static char *lookup_prog(const char *dir, int dirlen, const char *cmd,
998998
int isexe, int exe_only)
999999
{
10001000
char path[MAX_PATH];
1001+
wchar_t wpath[MAX_PATH];
10011002
snprintf(path, sizeof(path), "%.*s\\%s.exe", dirlen, dir, cmd);
10021003

1003-
if (!isexe && access(path, F_OK) == 0)
1004+
if (xutftowcs_path(wpath, path) < 0)
1005+
return NULL;
1006+
1007+
if (!isexe && _waccess(wpath, F_OK) == 0)
10041008
return xstrdup(path);
1005-
path[strlen(path)-4] = '\0';
1006-
if ((!exe_only || isexe) && access(path, F_OK) == 0)
1007-
if (!(GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY))
1009+
wpath[wcslen(wpath)-4] = '\0';
1010+
if ((!exe_only || isexe) && _waccess(wpath, F_OK) == 0) {
1011+
if (!(GetFileAttributesW(wpath) & FILE_ATTRIBUTE_DIRECTORY)) {
1012+
path[strlen(path)-4] = '\0';
10081013
return xstrdup(path);
1014+
}
1015+
}
10091016
return NULL;
10101017
}
10111018

0 commit comments

Comments
 (0)