idevicebackup2: Fix scan_directory() for platforms not having d_type in struct dirent
diff --git a/configure.ac b/configure.ac index ec210fc..69ff13b 100644 --- a/configure.ac +++ b/configure.ac
@@ -83,6 +83,8 @@ esac AM_CONDITIONAL(WIN32, test x$win32 = xtrue) +AC_CHECK_MEMBER(struct dirent.d_type, AC_DEFINE(HAVE_DIRENT_D_TYPE, 1, [define if struct dirent has member d_type]),, [#include <dirent.h>]) + # Cython Python Bindings AC_ARG_WITH([cython], [AS_HELP_STRING([--without-cython],
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 02611a1..f7ea53a 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c
@@ -254,7 +254,13 @@ } char *fpath = string_build_path(path, ep->d_name, NULL); if (fpath) { +#ifdef HAVE_DIRENT_D_TYPE if (ep->d_type & DT_DIR) { +#else + struct stat st; + if (stat(fpath, &st) != 0) return; + if (S_ISDIR(st.st_mode)) { +#endif struct entry *ent = malloc(sizeof(struct entry)); if (!ent) return; ent->name = fpath;