From: Eli Zaretskii Date: Mon, 20 Jan 2020 16:21:09 +0000 (+0200) Subject: Unbreak the MS-Windows build X-Git-Tag: emacs-28.0.90~7908^2~89 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f650d54c6a3620d3b1c264a944023beea15fe394;p=emacs.git Unbreak the MS-Windows build * src/w32.c (openat): New function. * src/w32.h (openat): Add prototype. --- diff --git a/src/w32.c b/src/w32.c index 62c53fd7711..a3b9a5683ad 100644 --- a/src/w32.c +++ b/src/w32.c @@ -4591,6 +4591,27 @@ sys_open (const char * path, int oflag, int mode) return res; } +int +openat (int fd, const char * path, int oflag, int mode) +{ + /* Rely on a hack: an open directory is modeled as file descriptor 0, + as in fstatat. FIXME: Add proper support for openat. */ + char fullname[MAX_UTF8_PATH]; + + if (fd != AT_FDCWD) + { + if (_snprintf (fullname, sizeof fullname, "%s/%s", dir_pathname, path) + < 0) + { + errno = ENAMETOOLONG; + return -1; + } + path = fullname; + } + + return sys_open (path, oflag, mode); +} + int fchmod (int fd, mode_t mode) { diff --git a/src/w32.h b/src/w32.h index b8655ec788c..f301b3836ca 100644 --- a/src/w32.h +++ b/src/w32.h @@ -221,6 +221,7 @@ extern void register_child (pid_t, int); extern void sys_sleep (int); extern int sys_link (const char *, const char *); +extern int openat (int, const char *, int, int); /* Return total and free memory info. */ extern int w32_memory_info (unsigned long long *, unsigned long long *,