Skip to content

Commit 6fb74b9

Browse files
committed
Merge 'fix-externals' into HEAD
2 parents 88d97d8 + 2ae2f97 commit 6fb74b9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

compat/mingw.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,14 +1016,21 @@ static void free_path_split(char **path)
10161016
static char *lookup_prog(const char *dir, const char *cmd, int isexe, int exe_only)
10171017
{
10181018
char path[MAX_PATH];
1019-
snprintf(path, sizeof(path), "%s/%s.exe", dir, cmd);
1019+
wchar_t wpath[MAX_PATH];
1020+
snprintf(path, sizeof(path), "%s\\%s.exe", dir, cmd);
10201021

1021-
if (!isexe && access(path, F_OK) == 0)
1022+
if (xutftowcs_path(wpath, path) < 0)
1023+
return NULL;
1024+
1025+
if (!isexe && _waccess(wpath, F_OK) == 0)
10221026
return xstrdup(path);
1023-
path[strlen(path)-4] = '\0';
1024-
if ((!exe_only || isexe) && access(path, F_OK) == 0)
1025-
if (!(GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY))
1027+
wpath[wcslen(wpath)-4] = '\0';
1028+
if ((!exe_only || isexe) && _waccess(wpath, F_OK) == 0) {
1029+
if (!(GetFileAttributesW(wpath) & FILE_ATTRIBUTE_DIRECTORY)) {
1030+
path[strlen(path)-4] = '\0';
10261031
return xstrdup(path);
1032+
}
1033+
}
10271034
return NULL;
10281035
}
10291036

0 commit comments

Comments
 (0)