* Fix forgotten initialization of eina list count during eina_list_split_list.
+2012-02-22 Cedric Bail
+
+ * Add eina_file_stat.
* Added eina_inarray data type
* Added eina_value data type (generic value storage)
* Added eina_model data type (generic hierarchy data access)
+ * Add eina_file_stat.
Fixes:
#include <limits.h>
#include <time.h>
+#include <sys/stat.h>
#include "eina_types.h"
#include "eina_array.h"
EAPI Eina_Iterator *eina_file_stat_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
/**
+ * @brief Use information provided by Eina_Iterator of eina_file_stat_ls or eina_file_direct_ls
+ * to call stat in the most efficient way on your system.
+ *
+ * @param container The container returned by the Eina_Iterator.
+ * @param info The content of the curently Eina_File_Direct_Info provided by the Eina_Iterator
+ * @param buf Where to put the result of the stat
+ * @return On success 0 is returned, On error -1 is returned and errno is set appropriatly.
+ *
+ * This function call fstatat or stat depending on what your system support. This make it efficient and simple
+ * to use on your side without complex detection already done inside Eina on what the system can do.
+ *
+ * @see eina_file_direct_ls()
+ * @see eina_file_stat_ls()
+ */
+EAPI int eina_file_stat(void *container, Eina_File_Direct_Info *info, struct stat *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2, 3);
+
+/**
* @brief Get an iterator to list the content of a directory, with direct
* information.
*
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
+ if (eina_file_stat(it->dirp, &it->info, &st))
it->info.type = EINA_FILE_UNKNOWN;
else
{
eina_lock_release(&_eina_file_lock_cache);
}
+EAPI int
+eina_file_stat(void *container, Eina_File_Direct_Info *info, struct stat *buf)
+{
+#ifdef HAVE_FSTATAT
+ int fd;
+#endif
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(info, -1);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(buf, -1);
+
+#ifdef HAVE_FSTATAT
+ fd = dirfd(container);
+ return fstatat(fd, info->path + info->name_start, buf, 0);
+#else
+ return stat(it->info.path, buf);
+#endif
+}