Skip to content

Commit 4a87acf

Browse files
committed
Merge 'fix-externals' into HEAD
2 parents 47e6fba + 1ba092b commit 4a87acf

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
@@ -1001,14 +1001,21 @@ static void free_path_split(char **path)
10011001
static char *lookup_prog(const char *dir, const char *cmd, int isexe, int exe_only)
10021002
{
10031003
char path[MAX_PATH];
1004-
snprintf(path, sizeof(path), "%s/%s.exe", dir, cmd);
1004+
wchar_t wpath[MAX_PATH];
1005+
snprintf(path, sizeof(path), "%s\\%s.exe", dir, cmd);
10051006

1006-
if (!isexe && access(path, F_OK) == 0)
1007+
if (xutftowcs_path(wpath, path) < 0)
1008+
return NULL;
1009+
1010+
if (!isexe && _waccess(wpath, F_OK) == 0)
10071011
return xstrdup(path);
1008-
path[strlen(path)-4] = '\0';
1009-
if ((!exe_only || isexe) && access(path, F_OK) == 0)
1010-
if (!(GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY))
1012+
wpath[wcslen(wpath)-4] = '\0';
1013+
if ((!exe_only || isexe) && _waccess(wpath, F_OK) == 0) {
1014+
if (!(GetFileAttributesW(wpath) & FILE_ATTRIBUTE_DIRECTORY)) {
1015+
path[strlen(path)-4] = '\0';
10111016
return xstrdup(path);
1017+
}
1018+
}
10121019
return NULL;
10131020
}
10141021

0 commit comments

Comments
 (0)