-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Create a symlink relative to an open directory.
- Copyright (C) 2009-2013 Free Software Foundation, Inc.
+ Copyright (C) 2009-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <config.h>
#include <unistd.h>
+#include <errno.h>
-#if !HAVE_SYMLINK
+#if HAVE_SYMLINKAT
+# undef symlinkat
+
+#include <sys/stat.h>
+#include <string.h>
+
+/* Create a symlink, but reject trailing slash. */
+int
+rpl_symlinkat (char const *contents, int fd, char const *name)
+{
+ size_t len = strlen (name);
+ if (len && name[len - 1] == '/')
+ {
+ struct stat st;
+ if (fstatat (fd, name, &st, 0) == 0)
+ errno = EEXIST;
+ return -1;
+ }
+ return symlinkat (contents, fd, name);
+}
+
+#elif !HAVE_SYMLINK
/* Mingw lacks symlink, and it is more efficient to provide a trivial
wrapper than to go through at-func.c to call rpl_symlink. */
-# include <errno.h>
-
int
symlinkat (char const *path1 _GL_UNUSED, int fd _GL_UNUSED,
char const *path2 _GL_UNUSED)