Skip to content

Commit 472f41b

Browse files
committed
Merge 'fix-externals' into HEAD
2 parents c406a86 + cff62cd commit 472f41b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

compat/mingw.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -987,14 +987,21 @@ static char *lookup_prog(const char *dir, int dirlen, const char *cmd,
987987
int isexe, int exe_only)
988988
{
989989
char path[MAX_PATH];
990+
wchar_t wpath[MAX_PATH];
990991
snprintf(path, sizeof(path), "%.*s\\%s.exe", dirlen, dir, cmd);
991992

992-
if (!isexe && access(path, F_OK) == 0)
993+
if (xutftowcs_path(wpath, path) < 0)
994+
return NULL;
995+
996+
if (!isexe && _waccess(wpath, F_OK) == 0)
993997
return xstrdup(path);
994-
path[strlen(path)-4] = '\0';
995-
if ((!exe_only || isexe) && access(path, F_OK) == 0)
996-
if (!(GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY))
998+
wpath[wcslen(wpath)-4] = '\0';
999+
if ((!exe_only || isexe) && _waccess(wpath, F_OK) == 0) {
1000+
if (!(GetFileAttributesW(wpath) & FILE_ATTRIBUTE_DIRECTORY)) {
1001+
path[strlen(path)-4] = '\0';
9971002
return xstrdup(path);
1003+
}
1004+
}
9981005
return NULL;
9991006
}
10001007

0 commit comments

Comments
 (0)