Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit ca1a6ed

Browse files
committed
Merge 'fix-externals' into HEAD
2 parents 8673fdf + e959849 commit ca1a6ed

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
@@ -1013,14 +1013,21 @@ static void free_path_split(char **path)
10131013
static char *lookup_prog(const char *dir, const char *cmd, int isexe, int exe_only)
10141014
{
10151015
char path[MAX_PATH];
1016-
snprintf(path, sizeof(path), "%s/%s.exe", dir, cmd);
1016+
wchar_t wpath[MAX_PATH];
1017+
snprintf(path, sizeof(path), "%s\\%s.exe", dir, cmd);
1018+
1019+
if (xutftowcs_path(wpath, path) < 0)
1020+
return NULL;
10171021

1018-
if (!isexe && access(path, F_OK) == 0)
1022+
if (!isexe && _waccess(wpath, F_OK) == 0)
10191023
return xstrdup(path);
1020-
path[strlen(path)-4] = '\0';
1021-
if ((!exe_only || isexe) && access(path, F_OK) == 0)
1022-
if (!(GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY))
1024+
wpath[wcslen(wpath)-4] = '\0';
1025+
if ((!exe_only || isexe) && _waccess(wpath, F_OK) == 0) {
1026+
if (!(GetFileAttributesW(wpath) & FILE_ATTRIBUTE_DIRECTORY)) {
1027+
path[strlen(path)-4] = '\0';
10231028
return xstrdup(path);
1029+
}
1030+
}
10241031
return NULL;
10251032
}
10261033

0 commit comments

Comments
 (0)