use configure to detect dirent.d_type

This commit is contained in:
David Adam 2014-12-11 15:24:42 +08:00
parent b9db555343
commit a10f729ef9
3 changed files with 24 additions and 2 deletions

View file

@ -502,6 +502,10 @@ fi
AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
#
# Check for D_TYPE in dirent, only on BSD and Linux
#
AC_STRUCT_DIRENT_D_TYPE
#
# Check for presense of various functions used by fish

View file

@ -19,6 +19,10 @@
/* Define to 1 if you have the `dcgettext' function. */
/* #undef HAVE_DCGETTEXT */
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#define HAVE_DIRENT_H 1
/* Define to 1 if you have the <execinfo.h> header file. */
#define HAVE_EXECINFO_H 1
@ -70,6 +74,9 @@
/* Define to 1 if you have the <ncurses/term.h> header file. */
/* #undef HAVE_NCURSES_TERM_H */
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
/* #undef HAVE_NDIR_H */
/* Define to 1 if realpath accepts null for its second argument. */
#define HAVE_REALPATH_NULL 1
@ -97,12 +104,23 @@
/* Define to 1 if you have the <stropts.h> header file. */
/* #undef HAVE_STROPTS_H */
/* Define to 1 if `d_type' is a member of `struct dirent'. */
#define HAVE_STRUCT_DIRENT_D_TYPE 1
/* Define to 1 if you have the `sysconf' function. */
#define HAVE_SYSCONF 1
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_DIR_H */
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#define HAVE_SYS_IOCTL_H 1
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_NDIR_H */
/* Define to 1 if you have the <sys/resource.h> header file. */
#define HAVE_SYS_RESOURCE_H 1

View file

@ -81,7 +81,7 @@ bool wreaddir_resolving(DIR *dir, const std::wstring &dir_path, std::wstring &ou
/* We may be able to skip stat, if the readdir can tell us the file type directly */
bool check_with_stat = true;
#if defined(_DIRENT_HAVE_D_TYPE) || __APPLE__
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
if (d->d_type == DT_DIR)
{
/* Known directory */
@ -99,7 +99,7 @@ bool wreaddir_resolving(DIR *dir, const std::wstring &dir_path, std::wstring &ou
is_dir = false;
check_with_stat = false;
}
#endif
#endif // HAVE_STRUCT_DIRENT_D_TYPE
if (check_with_stat)
{
/* We couldn't determine the file type from the dirent; check by stat'ing it */