Skip to content

Commit a8e39d4

Browse files
committed
Merge 'fix-externals' into HEAD
2 parents cb4b9e1 + 5cca1ca commit a8e39d4

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
@@ -926,14 +926,21 @@ static void free_path_split(char **path)
926926
static char *lookup_prog(const char *dir, const char *cmd, int isexe, int exe_only)
927927
{
928928
char path[MAX_PATH];
929-
snprintf(path, sizeof(path), "%s/%s.exe", dir, cmd);
929+
wchar_t wpath[MAX_PATH];
930+
snprintf(path, sizeof(path), "%s\\%s.exe", dir, cmd);
931+
932+
if (xutftowcs_path(wpath, path) < 0)
933+
return NULL;
930934

931-
if (!isexe && access(path, F_OK) == 0)
935+
if (!isexe && _waccess(wpath, F_OK) == 0)
932936
return xstrdup(path);
933-
path[strlen(path)-4] = '\0';
934-
if ((!exe_only || isexe) && access(path, F_OK) == 0)
935-
if (!(GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY))
937+
wpath[wcslen(wpath)-4] = '\0';
938+
if ((!exe_only || isexe) && _waccess(wpath, F_OK) == 0) {
939+
if (!(GetFileAttributesW(wpath) & FILE_ATTRIBUTE_DIRECTORY)) {
940+
path[strlen(path)-4] = '\0';
936941
return xstrdup(path);
942+
}
943+
}
937944
return NULL;
938945
}
939946

0 commit comments

Comments
 (0)