Skip to content

Commit e4f3bac

Browse files
committed
Merge 'fix-externals' into HEAD
2 parents d2ee2d6 + ee27964 commit e4f3bac

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