diff options
author | Maxime Devos <maximedevos@telenet.be> | 2021-11-16 11:06:28 +0000 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2022-10-21 17:40:37 +0200 |
commit | 58ddd5c7bc3907c1f1e4dd9637d996c4d72eaba0 (patch) | |
tree | 6e4629c4094f7a36ba6c89574606b2e0cd18b555 /libguile/filesys.c | |
parent | 6c350b609475ec7c490a8faecedd6a768afd7065 (diff) | |
download | guile-58ddd5c7bc3907c1f1e4dd9637d996c4d72eaba0.tar.gz |
Define bindings to ‘mkdirat’ when the C function exists.
* 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 <ludo@gnu.org>
Diffstat (limited to 'libguile/filesys.c')
-rw-r--r-- | libguile/filesys.c | 25 |
1 files changed, 25 insertions, 0 deletions
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" |