Skip to content

Commit 2ea7b31

Browse files
committed
Merge 'fix-externals' into HEAD
2 parents d7c712b + aa5a337 commit 2ea7b31

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
@@ -935,14 +935,21 @@ static void free_path_split(char **path)
935935
static char *lookup_prog(const char *dir, const char *cmd, int isexe, int exe_only)
936936
{
937937
char path[MAX_PATH];
938-
snprintf(path, sizeof(path), "%s/%s.exe", dir, cmd);
938+
wchar_t wpath[MAX_PATH];
939+
snprintf(path, sizeof(path), "%s\\%s.exe", dir, cmd);
939940

940-
if (!isexe && access(path, F_OK) == 0)
941+
if (xutftowcs_path(wpath, path) < 0)
942+
return NULL;
943+
944+
if (!isexe && _waccess(wpath, F_OK) == 0)
941945
return xstrdup(path);
942-
path[strlen(path)-4] = '\0';
943-
if ((!exe_only || isexe) && access(path, F_OK) == 0)
944-
if (!(GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY))
946+
wpath[wcslen(wpath)-4] = '\0';
947+
if ((!exe_only || isexe) && _waccess(wpath, F_OK) == 0) {
948+
if (!(GetFileAttributesW(wpath) & FILE_ATTRIBUTE_DIRECTORY)) {
949+
path[strlen(path)-4] = '\0';
945950
return xstrdup(path);
951+
}
952+
}
946953
return NULL;
947954
}
948955

0 commit comments

Comments
 (0)