12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #include <features.h>
- #include <unistd.h>
- #include <sys/stat.h>
- #include <stdlib.h>
- #include <string.h>
- char *
- get_current_dir_name (void)
- {
- char *pwd;
- #if defined __UCLIBC_HAS_LFS__
- struct stat64 dotstat, pwdstat;
- #else
- struct stat dotstat, pwdstat;
- #endif
- pwd = getenv ("PWD");
- if (pwd != NULL
- #if defined __UCLIBC_HAS_LFS__
- && stat64 (".", &dotstat) == 0
- && stat64 (pwd, &pwdstat) == 0
- #else
- && stat (".", &dotstat) == 0
- && stat (pwd, &pwdstat) == 0
- #endif
- && pwdstat.st_dev == dotstat.st_dev
- && pwdstat.st_ino == dotstat.st_ino)
-
- return strdup (pwd);
- return getcwd ((char *) NULL, 0);
- }
|