Skip to content

Commit 437382d

Browse files
dschojamill
authored andcommitted
Merge 'fix-externals' into HEAD
2 parents b56bf98 + a2d11ea commit 437382d

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
@@ -1035,14 +1035,21 @@ static char *lookup_prog(const char *dir, int dirlen, const char *cmd,
10351035
int isexe, int exe_only)
10361036
{
10371037
char path[MAX_PATH];
1038+
wchar_t wpath[MAX_PATH];
10381039
snprintf(path, sizeof(path), "%.*s\\%s.exe", dirlen, dir, cmd);
10391040

1040-
if (!isexe && access(path, F_OK) == 0)
1041+
if (xutftowcs_path(wpath, path) < 0)
1042+
return NULL;
1043+
1044+
if (!isexe && _waccess(wpath, F_OK) == 0)
10411045
return xstrdup(path);
1042-
path[strlen(path)-4] = '\0';
1043-
if ((!exe_only || isexe) && access(path, F_OK) == 0)
1044-
if (!(GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY))
1046+
wpath[wcslen(wpath)-4] = '\0';
1047+
if ((!exe_only || isexe) && _waccess(wpath, F_OK) == 0) {
1048+
if (!(GetFileAttributesW(wpath) & FILE_ATTRIBUTE_DIRECTORY)) {
1049+
path[strlen(path)-4] = '\0';
10451050
return xstrdup(path);
1051+
}
1052+
}
10461053
return NULL;
10471054
}
10481055

0 commit comments

Comments
 (0)