diff options
author | Maxime Devos <maximedevos@telenet.be> | 2021-11-16 11:06:27 +0000 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2022-10-21 17:40:37 +0200 |
commit | 6c350b609475ec7c490a8faecedd6a768afd7065 (patch) | |
tree | 1ee7625de704e661e9a045a95bd8a4f5a24be6b7 /libguile/filesys.c | |
parent | 9ffd297249e8c99ac276b37c49725f6d2ef20b52 (diff) | |
download | guile-6c350b609475ec7c490a8faecedd6a768afd7065.tar.gz |
Define ‘symlinkat’ wrapper when supported.
* configure.ac: Detect whether ‘symlinkat’ exists.
* libguile/filesys.c (scm_symlinkat): Define a Scheme binding
when it exists.
* libguile/filesys.h: Make the binding part of the public C API.
* doc/ref/posix.texi (File System): Document the binding.
* test-suite/tests/filesys.test ("symlinkat"): Test it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'libguile/filesys.c')
-rw-r--r-- | libguile/filesys.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libguile/filesys.c b/libguile/filesys.c index 1ae2c5de7..e00ddba5f 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -1032,6 +1032,29 @@ SCM_DEFINE (scm_symlink, "symlink", 2, 0, 0, #undef FUNC_NAME #endif /* HAVE_SYMLINK */ +#ifdef HAVE_SYMLINKAT +SCM_DEFINE (scm_symlinkat, "symlinkat", 3, 0, 0, + (SCM dir, SCM oldpath, SCM newpath), + "Like @code{symlink}, but resolve @var{newpath} relative\n" + "to the directory referred to by the file port @var{dir}.") +#define FUNC_NAME s_scm_symlinkat +{ + int val; + int fdes; + + SCM_VALIDATE_OPFPORT (SCM_ARG1, dir); + fdes = SCM_FPORT_FDES (dir); + STRING2_SYSCALL (oldpath, c_oldpath, + newpath, c_newpath, + val = symlinkat (c_oldpath, fdes, c_newpath)); + scm_remember_upto_here_1 (dir); + if (val != 0) + SCM_SYSERROR; + return SCM_UNSPECIFIED; +} +#undef FUNC_NAME +#endif /* HAVE_SYMLINKAT */ + /* Static helper function for choosing between readlink and readlinkat. */ static int |