From: Enlightenment S. <no-...@en...> - 2011-11-20 15:10:12
|
Log: evas: use Eina_File for a more porable and cleaner code. Author: cedric Date: 2011-11-20 07:10:05 -0800 (Sun, 20 Nov 2011) New Revision: 65450 Trac: http://trac.enlightenment.org/e/changeset/65450 Modified: trunk/evas/src/lib/file/evas_path.c Modified: trunk/evas/src/lib/file/evas_path.c =================================================================== --- trunk/evas/src/lib/file/evas_path.c 2011-11-20 15:00:43 UTC (rev 65449) +++ trunk/evas/src/lib/file/evas_path.c 2011-11-20 15:10:05 UTC (rev 65450) @@ -13,7 +13,6 @@ #include <sys/stat.h> /* get the casefold feature! */ #include <fnmatch.h> -#include <dirent.h> #ifndef _MSC_VER # include <unistd.h> # include <sys/param.h> @@ -100,36 +99,31 @@ Eina_List * evas_file_path_list(char *path, const char *match, int match_case) { + Eina_File_Direct_Info *info; + Eina_Iterator *it; Eina_List *files = NULL; - DIR *dir; + int flags; - dir = opendir(path); - if (!dir) return NULL; - { - struct dirent *dp; - int flags; - - flags = FNM_PATHNAME; + flags = FNM_PATHNAME; #ifdef FNM_CASEFOLD - if (!match_case) - flags |= FNM_CASEFOLD; + if (!match_case) + flags |= FNM_CASEFOLD; #else /*#warning "Your libc does not provide case-insensitive matching!"*/ #endif - while ((dp = readdir(dir))) - { - if ((!strcmp(dp->d_name, ".")) || (!strcmp(dp->d_name, ".."))) - continue; - if (match) - { - if (fnmatch(match, dp->d_name, flags) == 0) - files = eina_list_append(files, strdup(dp->d_name)); - } - else - files = eina_list_append(files, strdup(dp->d_name)); - } - closedir(dir); + + it = eina_file_direct_ls(path); + EINA_ITERATOR_FOREACH(it, info) + { + if (match) + { + if (fnmatch(match, info->path + info->name_start, flags) == 0) + files = eina_list_append(files, strdup(info->path + info->name_start)); + } + else + files = eina_list_append(files, strdup(info->path + info->name_start)); } + eina_iterator_free(it); return files; } |