Skip to content

Commit 5bed8dc

Browse files
author
Git for Windows Build Agent
committed
Merge 'fix-externals' into HEAD
2 parents 28cbad8 + 3732c02 commit 5bed8dc

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
@@ -994,14 +994,21 @@ static void free_path_split(char **path)
994994
static char *lookup_prog(const char *dir, const char *cmd, int isexe, int exe_only)
995995
{
996996
char path[MAX_PATH];
997-
snprintf(path, sizeof(path), "%s/%s.exe", dir, cmd);
997+
wchar_t wpath[MAX_PATH];
998+
snprintf(path, sizeof(path), "%s\\%s.exe", dir, cmd);
998999

999-
if (!isexe && access(path, F_OK) == 0)
1000+
if (xutftowcs_path(wpath, path) < 0)
1001+
return NULL;
1002+
1003+
if (!isexe && _waccess(wpath, F_OK) == 0)
10001004
return xstrdup(path);
1001-
path[strlen(path)-4] = '\0';
1002-
if ((!exe_only || isexe) && access(path, F_OK) == 0)
1003-
if (!(GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY))
1005+
wpath[wcslen(wpath)-4] = '\0';
1006+
if ((!exe_only || isexe) && _waccess(wpath, F_OK) == 0) {
1007+
if (!(GetFileAttributesW(wpath) & FILE_ATTRIBUTE_DIRECTORY)) {
1008+
path[strlen(path)-4] = '\0';
10041009
return xstrdup(path);
1010+
}
1011+
}
10051012
return NULL;
10061013
}
10071014

0 commit comments

Comments
 (0)