* eina: use fstatat when available.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 2 Nov 2010 17:47:19 +0000 (17:47 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 2 Nov 2010 17:47:19 +0000 (17:47 +0000)
Maybe we could add an eina_file_lstat_ls.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@54108 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

configure.ac
src/lib/eina_file.c

index 44637de..f7031ac 100644 (file)
@@ -522,6 +522,14 @@ if test "x${have_iconv}" = "xyes" ; then
    AC_DEFINE([HAVE_ICONV], [1], [Set to 1 if iconv library is installed])
 fi
 
+#check for dirfd API presence
+have_dirfd="no"
+AC_CHECK_FUNCS([dirfd], [have_dirfd="yes"], [])
+if test "x${dirfd}" = "xyes"; then
+   AC_DEFINE(HAVE_DIRFD)
+fi
+AC_CHECK_FUNCS([openat], [AC_DEFINE(HAVE_OPENAT)], [])
+AC_CHECK_FUNCS([statat], [AC_DEFINE(HAVE_STATAT)], [])
 
 ### Modules
 
@@ -626,6 +634,7 @@ echo "    debug usage........: ${have_debug_threads}"
 fi
 echo "  Amalgamation.........: ${do_amalgamation}"
 echo "  Iconv support........: ${have_iconv}"
+echo "  File dirfd...........: ${have_dirfd}"
 echo
 echo "  Documentation........: ${build_doc}"
 echo "  Tests................: ${enable_tests}"
index c3c5335..b12431e 100644 (file)
@@ -240,7 +240,14 @@ _eina_file_stat_ls_iterator_next(Eina_File_Direct_Iterator *it, void **data)
 
    if (it->info.type == EINA_FILE_UNKNOWN)
      {
+#ifdef HAVE_FSTATAT
+        int fd;
+
+        fd = dirfd(it->dirp);
+        if (fstatat(fd, it->info.path + it->info.name_start, &st, 0))
+#else
         if (stat(it->info.path, &st))
+#endif
           it->info.type = EINA_FILE_UNKNOWN;
         else
           {