From 58ddd5c7bc3907c1f1e4dd9637d996c4d72eaba0 Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Tue, 16 Nov 2021 11:06:28 +0000 Subject: Define bindings to ‘mkdirat’ when the C function exists. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * configure.ac: Detect if ‘mkdirat’ exists. * libguile/filesys.c (scm_mkdirat): Define the Scheme binding. * doc/ref/posix.texi (File System): Document it. Signed-off-by: Ludovic Courtès --- libguile/filesys.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'libguile/filesys.c') diff --git a/libguile/filesys.c b/libguile/filesys.c index e00ddba5f..29787a83f 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -1351,6 +1351,31 @@ SCM_DEFINE (scm_mkdir, "mkdir", 1, 1, 0, } #undef FUNC_NAME +#ifdef HAVE_MKDIRAT +SCM_DEFINE (scm_mkdirat, "mkdirat", 2, 1, 0, + (SCM dir, SCM path, SCM mode), + "Like @code{mkdir}, but resolve @var{path} relative to the directory\n" + "referred to by the file port @var{dir} instead.") +#define FUNC_NAME s_scm_mkdirat +{ + int rv; + int dir_fdes; + mode_t c_mode; + + c_mode = SCM_UNBNDP (mode) ? 0777 : scm_to_uint (mode); + SCM_VALIDATE_OPFPORT (SCM_ARG1, dir); + dir_fdes = SCM_FPORT_FDES (dir); + + STRING_SYSCALL (path, c_path, rv = mkdirat (dir_fdes, c_path, c_mode)); + if (rv != 0) + SCM_SYSERROR; + + scm_remember_upto_here_1 (dir); + return SCM_UNSPECIFIED; +} +#undef FUNC_NAME +#endif + SCM_DEFINE (scm_rmdir, "rmdir", 1, 0, 0, (SCM path), "Remove the existing directory named by @var{path}. The directory must\n" -- cgit v1.2.3