Skip to content

Commit 40dc8e3

Browse files
committed
Merge 'fix-externals' into HEAD
2 parents c89ba59 + bad9944 commit 40dc8e3

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
@@ -923,14 +923,21 @@ static void free_path_split(char **path)
923923
static char *lookup_prog(const char *dir, const char *cmd, int isexe, int exe_only)
924924
{
925925
char path[MAX_PATH];
926-
snprintf(path, sizeof(path), "%s/%s.exe", dir, cmd);
926+
wchar_t wpath[MAX_PATH];
927+
snprintf(path, sizeof(path), "%s\\%s.exe", dir, cmd);
927928

928-
if (!isexe && access(path, F_OK) == 0)
929+
if (xutftowcs_path(wpath, path) < 0)
930+
return NULL;
931+
932+
if (!isexe && _waccess(wpath, F_OK) == 0)
929933
return xstrdup(path);
930-
path[strlen(path)-4] = '\0';
931-
if ((!exe_only || isexe) && access(path, F_OK) == 0)
932-
if (!(GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY))
934+
wpath[wcslen(wpath)-4] = '\0';
935+
if ((!exe_only || isexe) && _waccess(wpath, F_OK) == 0) {
936+
if (!(GetFileAttributesW(wpath) & FILE_ATTRIBUTE_DIRECTORY)) {
937+
path[strlen(path)-4] = '\0';
933938
return xstrdup(path);
939+
}
940+
}
934941
return NULL;
935942
}
936943

0 commit comments

Comments
 (0)