Skip to content

Commit 82fd095

Browse files
committed
Merge 'fix-externals' into HEAD
2 parents 18ba56c + 2b73d82 commit 82fd095

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
@@ -918,14 +918,21 @@ static void free_path_split(char **path)
918918
static char *lookup_prog(const char *dir, const char *cmd, int isexe, int exe_only)
919919
{
920920
char path[MAX_PATH];
921-
snprintf(path, sizeof(path), "%s/%s.exe", dir, cmd);
921+
wchar_t wpath[MAX_PATH];
922+
snprintf(path, sizeof(path), "%s\\%s.exe", dir, cmd);
922923

923-
if (!isexe && access(path, F_OK) == 0)
924+
if (xutftowcs_path(wpath, path) < 0)
925+
return NULL;
926+
927+
if (!isexe && _waccess(wpath, F_OK) == 0)
924928
return xstrdup(path);
925-
path[strlen(path)-4] = '\0';
926-
if ((!exe_only || isexe) && access(path, F_OK) == 0)
927-
if (!(GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY))
929+
wpath[wcslen(wpath)-4] = '\0';
930+
if ((!exe_only || isexe) && _waccess(wpath, F_OK) == 0) {
931+
if (!(GetFileAttributesW(wpath) & FILE_ATTRIBUTE_DIRECTORY)) {
932+
path[strlen(path)-4] = '\0';
928933
return xstrdup(path);
934+
}
935+
}
929936
return NULL;
930937
}
931938

0 commit comments

Comments
 (0)