diff options
author | Eli Zaretskii <eliz@gnu.org> | 2017-08-12 14:44:20 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2017-08-12 14:44:20 +0300 |
commit | fce2b2d2b40a1c0505d1ad623baef76f726c436a (patch) | |
tree | b47d40c2cc59399db224828d8682c30cabdb1f87 /src/msdos.c | |
parent | ec5cfaa4568327b5b0b299be2664f7fdae123292 (diff) | |
download | emacs-fce2b2d2b40a1c0505d1ad623baef76f726c436a.tar.gz |
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.
Diffstat (limited to 'src/msdos.c')
-rw-r--r-- | src/msdos.c | 17 |
1 files changed, 15 insertions, 2 deletions
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); } |