From fce2b2d2b40a1c0505d1ad623baef76f726c436a Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 12 Aug 2017 14:44:20 +0300 Subject: Fix completion on directory names on MS-DOS/MS-Windows * src/msdos.c (faccessat): * src/w32.c (faccessat): Support relative file names, and add D_OK to 'mode' if the argument is a directory. This unbreaks file-name completion when the completion result is a directory. --- src/msdos.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/msdos.c') diff --git a/src/msdos.c b/src/msdos.c index 87b6f84148c..5b025753d98 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -3950,10 +3950,23 @@ faccessat (int dirfd, const char * path, int mode, int flags) && !(IS_DIRECTORY_SEP (path[0]) || IS_DEVICE_SEP (path[1]))) { - errno = EBADF; - return -1; + char lastc = dir_pathname[strlen (dir_pathname) - 1]; + + if (strlen (dir_pathname) + strlen (path) + IS_DIRECTORY_SEP (lastc) + >= MAXPATHLEN) + { + errno = ENAMETOOLONG; + return -1; + } + + sprintf (fullname, "%s%s%s", + dir_pathname, IS_DIRECTORY_SEP (lastc) ? "" : "/", path); + path = fullname; } + if ((mode & F_OK) != 0 && IS_DIRECTORY_SEP (path[strlen (path) - 1])) + mode |= D_OK; + return access (path, mode); } -- cgit v1.2.1