123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #include <config.h>
- #include <unistd.h>
- #include <errno.h>
- #include <string.h>
- #include <sys/stat.h>
- #if !HAVE_READLINK
- ssize_t
- readlink (const char *name, char *buf _GL_UNUSED,
- size_t bufsize _GL_UNUSED)
- {
- struct stat statbuf;
-
- if (stat (name, &statbuf) >= 0)
- errno = EINVAL;
- return -1;
- }
- #else
- # undef readlink
- ssize_t
- rpl_readlink (const char *name, char *buf, size_t bufsize)
- {
- # if READLINK_TRAILING_SLASH_BUG
- size_t len = strlen (name);
- if (len && name[len - 1] == '/')
- {
-
- struct stat st;
- if (stat (name, &st) == 0)
- errno = EINVAL;
- return -1;
- }
- # endif
- return readlink (name, buf, bufsize);
- }
- #endif
|