Skip to content

Commit 6c80092

Browse files
committed
Merge 'fix-externals' into HEAD
2 parents 3ac4881 + dc36af7 commit 6c80092

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

929-
if (!isexe && access(path, F_OK) == 0)
933+
if (!isexe && _waccess(wpath, F_OK) == 0)
930934
return xstrdup(path);
931-
path[strlen(path)-4] = '\0';
932-
if ((!exe_only || isexe) && access(path, F_OK) == 0)
933-
if (!(GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY))
935+
wpath[wcslen(wpath)-4] = '\0';
936+
if ((!exe_only || isexe) && _waccess(wpath, F_OK) == 0) {
937+
if (!(GetFileAttributesW(wpath) & FILE_ATTRIBUTE_DIRECTORY)) {
938+
path[strlen(path)-4] = '\0';
934939
return xstrdup(path);
940+
}
941+
}
935942
return NULL;
936943
}
937944

0 commit comments

Comments
 (0)