e: move everyone to use eina_file_direct_ls and friend.

NOTE: I think, but I am not sure yet, that only EFM should
do this kind of operation or it could hard lock E17.


SVN revision: 70546
This commit is contained in:
Cedric BAIL 2012-04-30 07:07:33 +00:00
parent c90e3c1517
commit 70d21a1f44
6 changed files with 149 additions and 142 deletions

View File

@ -158,7 +158,7 @@ static void _e_fm_ipc_file_mon_list_sync(E_Dir *ed);
static Eina_Bool _e_fm_ipc_cb_file_mon_list_idler(void *data); static Eina_Bool _e_fm_ipc_cb_file_mon_list_idler(void *data);
static Eina_Bool _e_fm_ipc_cb_fop_trash_idler(void *data); static Eina_Bool _e_fm_ipc_cb_fop_trash_idler(void *data);
static char *_e_str_list_remove(Eina_List **list, char *str); static char *_e_str_list_remove(Eina_List **list, const char *str, int len);
static void _e_fm_ipc_reorder(const char *file, const char *dst, const char *relative, int after); static void _e_fm_ipc_reorder(const char *file, const char *dst, const char *relative, int after);
static void _e_fm_ipc_dir_del(E_Dir *ed); static void _e_fm_ipc_dir_del(E_Dir *ed);
@ -241,8 +241,8 @@ static void
_e_fm_ipc_monitor_start_try(E_Fm_Task *task) _e_fm_ipc_monitor_start_try(E_Fm_Task *task)
{ {
E_Dir *ed, *ped = NULL; E_Dir *ed, *ped = NULL;
Eina_Iterator *it;
DIR *dir;
Eina_List *l; Eina_List *l;
/* look for any previous dir entries monitoring this dir */ /* look for any previous dir entries monitoring this dir */
@ -257,8 +257,8 @@ _e_fm_ipc_monitor_start_try(E_Fm_Task *task)
} }
/* open the dir to list */ /* open the dir to list */
dir = opendir(task->src); it = eina_file_direct_ls(task->src);
if (!dir) if (!it)
{ {
char buf[PATH_MAX + 4096]; char buf[PATH_MAX + 4096];
@ -267,11 +267,9 @@ _e_fm_ipc_monitor_start_try(E_Fm_Task *task)
} }
else else
{ {
Eina_File_Direct_Info *info;
Eina_List *files = NULL; Eina_List *files = NULL;
struct dirent *dp; char *dot_order = NULL;
int dot_order = 0;
char buf[4096];
FILE *f;
/* create a new dir entry */ /* create a new dir entry */
ed = calloc(1, sizeof(E_Dir)); ed = calloc(1, sizeof(E_Dir));
@ -293,41 +291,65 @@ _e_fm_ipc_monitor_start_try(E_Fm_Task *task)
_e_dirs = eina_list_append(_e_dirs, ed); _e_dirs = eina_list_append(_e_dirs, ed);
/* read everything except a .order, . and .. */ /* read everything except a .order, . and .. */
while ((dp = readdir(dir))) EINA_ITERATOR_FOREACH(it, info)
{ {
if ((!strcmp(dp->d_name, ".")) || (!strcmp(dp->d_name, ".."))) if (!strcmp(info->path + info->name_start, ".order"))
continue;
if (!strcmp(dp->d_name, ".order"))
{ {
dot_order = 1; dot_order = strdup(info->path);
continue; continue;
} }
files = eina_list_append(files, strdup(dp->d_name)); files = eina_list_append(files, eina_stringshare_add(info->path + info->name_start));
} }
closedir(dir); eina_iterator_free(it);
/* if there was a .order - we need to parse it */ /* if there was a .order - we need to parse it */
if (dot_order) if (dot_order)
{ {
snprintf(buf, sizeof(buf), "%s/.order", task->src); Eina_File *f;
f = fopen(buf, "r");
f = eina_file_open(dot_order, EINA_FALSE);
if (f) if (f)
{ {
Eina_List *f2 = NULL; Eina_List *f2 = NULL;
int len; char *map;
char *s;
/* This piece of code should really become generic and work like an iterator.
* I plan to add this feature in eina, but that would be for next generation of E,
* not E17.
*/
map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
if (map)
{
const char *current = map;
const char *found;
size_t length = eina_file_size_get(f);
/* inset files in order if the existed in file /* inset files in order if the existed in file
* list before */ * list before */
while (fgets(buf, sizeof(buf), f)) while ((found = memchr(current, '\n', length)))
{ {
len = strlen(buf); if (found - current > 1)
if (len > 0) buf[len - 1] = 0; {
s = _e_str_list_remove(&files, buf); char *s = _e_str_list_remove(&files, current, found - current - 1);
if (s) f2 = eina_list_append(f2, s); if (s) f2 = eina_list_append(f2, s);
} }
fclose(f); length -= found - current - 1;
current = found + 1;
}
if (found == NULL && length > 0)
{
char *s = _e_str_list_remove(&files, current, length);
if (s) f2 = eina_list_append(f2, s);
}
/* append whats left */ /* append whats left */
files = eina_list_merge(f2, files); files = eina_list_merge(f2, files);
eina_file_map_free(f, map);
}
eina_file_close(f);
} }
} }
ed->fq = files; ed->fq = files;
@ -339,25 +361,23 @@ _e_fm_ipc_monitor_start_try(E_Fm_Task *task)
* .order file stuff here - but not today * .order file stuff here - but not today
*/ */
/* note that we had a .order at all */ /* note that we had a .order at all */
ed->dot_order = dot_order; ed->dot_order = dot_order ? EINA_TRUE : EINA_FALSE;
if (dot_order) if (dot_order)
{ {
/* if we did - tell the E about this FIRST - it will /* if we did - tell the E about this FIRST - it will
* decide what to do if it first sees a .order or not */ * decide what to do if it first sees a .order or not */
if (!strcmp(task->src, "/"))
snprintf(buf, sizeof(buf), "/.order");
else
snprintf(buf, sizeof(buf), "%s/.order", task->src);
if (eina_list_count(files) == 1) if (eina_list_count(files) == 1)
_e_fm_ipc_file_add(ed, buf, 2); _e_fm_ipc_file_add(ed, dot_order, 2);
else else
_e_fm_ipc_file_add(ed, buf, 1); _e_fm_ipc_file_add(ed, dot_order, 1);
} }
/* send empty file - indicate empty dir */ /* send empty file - indicate empty dir */
if (!files) _e_fm_ipc_file_add(ed, "", 2); if (!files) _e_fm_ipc_file_add(ed, "", 2);
/* and in an idler - list files, statting them etc. */ /* and in an idler - list files, statting them etc. */
ed->idler = ecore_idler_add(_e_fm_ipc_cb_file_mon_list_idler, ed); ed->idler = ecore_idler_add(_e_fm_ipc_cb_file_mon_list_idler, ed);
ed->sync_num = DEF_SYNC_NUM; ed->sync_num = DEF_SYNC_NUM;
free(dot_order);
} }
} }
@ -1148,7 +1168,7 @@ _e_fm_ipc_cb_file_mon_list_idler(void *data)
snprintf(buf, sizeof(buf), "%s/%s", ed->dir, file); snprintf(buf, sizeof(buf), "%s/%s", ed->dir, file);
_e_fm_ipc_file_add(ed, buf, 1); _e_fm_ipc_file_add(ed, buf, 1);
} }
free(file); eina_stringshare_del(file);
ed->fq = eina_list_remove_list(ed->fq, ed->fq); ed->fq = eina_list_remove_list(ed->fq, ed->fq);
n++; n++;
if (n == ed->sync_num) if (n == ed->sync_num)
@ -1251,13 +1271,13 @@ _e_fm_ipc_cb_fop_trash_idler(void *data)
} }
static char * static char *
_e_str_list_remove(Eina_List **list, char *str) _e_str_list_remove(Eina_List **list, const char *str, int len)
{ {
Eina_List *l; Eina_List *l;
char *s; char *s;
EINA_LIST_FOREACH(*list, l, s) EINA_LIST_FOREACH(*list, l, s)
if (!strcmp(s, str)) if (!strncmp(s, str, len))
{ {
*list = eina_list_remove_list(*list, l); *list = eina_list_remove_list(*list, l);
return s; return s;
@ -1357,7 +1377,7 @@ _e_fm_ipc_dir_del(E_Dir *ed)
free(m); free(m);
} }
EINA_LIST_FREE(ed->fq, data) EINA_LIST_FREE(ed->fq, data)
free(data); eina_stringshare_del(data);
free(ed); free(ed);
} }

View File

@ -731,8 +731,7 @@ _e_fm_op_scan_idler(void *data __UNUSED__)
static Eina_List *node = NULL; static Eina_List *node = NULL;
E_Fm_Op_Task *task = NULL; E_Fm_Op_Task *task = NULL;
char buf[PATH_MAX]; char buf[PATH_MAX];
static struct dirent *de = NULL; static Eina_Iterator *dir = NULL;
static DIR *dir = NULL;
E_Fm_Op_Task *ntask = NULL; E_Fm_Op_Task *ntask = NULL;
if (!node) node = _e_fm_op_scan_queue; if (!node) node = _e_fm_op_scan_queue;
@ -780,7 +779,7 @@ _e_fm_op_scan_idler(void *data __UNUSED__)
{ {
/* If it's a dir, then look through it and add a task for each. */ /* If it's a dir, then look through it and add a task for each. */
dir = opendir(task->src.name); dir = eina_file_direct_ls(task->src.name);
if (!dir) if (!dir)
_E_FM_OP_ERROR_SEND_SCAN(task, E_FM_OP_ERROR, _E_FM_OP_ERROR_SEND_SCAN(task, E_FM_OP_ERROR,
"Cannot open directory '%s': %s.", "Cannot open directory '%s': %s.",
@ -797,9 +796,9 @@ _e_fm_op_scan_idler(void *data __UNUSED__)
} }
else if (dir && !task->started) else if (dir && !task->started)
{ {
de = readdir(dir); Eina_File_Direct_Info *info;
if (!de) if (!eina_iterator_next(dir, (void**) &info))
{ {
ntask = _e_fm_op_task_new(); ntask = _e_fm_op_task_new();
ntask->type = E_FM_OP_COPY_STAT_INFO; ntask->type = E_FM_OP_COPY_STAT_INFO;
@ -819,23 +818,19 @@ _e_fm_op_scan_idler(void *data __UNUSED__)
eina_list_append(_e_fm_op_scan_queue, ntask); eina_list_append(_e_fm_op_scan_queue, ntask);
task->started = 1; task->started = 1;
closedir(dir); eina_iterator_free(dir);
dir = NULL; dir = NULL;
node = NULL; node = NULL;
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
if ((!strcmp(de->d_name, ".") || (!strcmp(de->d_name, ".."))))
return ECORE_CALLBACK_RENEW;
ntask = _e_fm_op_task_new(); ntask = _e_fm_op_task_new();
ntask->type = task->type; ntask->type = task->type;
snprintf(buf, sizeof(buf), "%s/%s", task->src.name, de->d_name); ntask->src.name = eina_stringshare_add(info->path);
ntask->src.name = eina_stringshare_add(buf);
if (task->dst.name) if (task->dst.name)
{ {
snprintf(buf, sizeof(buf), "%s/%s", task->dst.name, de->d_name); snprintf(buf, sizeof(buf), "%s/%s", task->dst.name, info->path + info->name_start);
ntask->dst.name = eina_stringshare_add(buf); ntask->dst.name = eina_stringshare_add(buf);
} }
else else

View File

@ -21,7 +21,7 @@ struct _Info
int iw, ih; int iw, ih;
Eina_List *dirs; Eina_List *dirs;
char *curdir; char *curdir;
DIR *dir; Eina_Iterator *dir;
Ecore_Idler *idler; Ecore_Idler *idler;
int scans; int scans;
int con_num, zone_num, desk_x, desk_y; int con_num, zone_num, desk_x, desk_y;
@ -1050,8 +1050,7 @@ _wp_changed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__
static Eina_Bool static Eina_Bool
_idler(void *data) _idler(void *data)
{ {
struct dirent *dp; Eina_File_Direct_Info *st;
char buf[PATH_MAX];
Info *info = data; Info *info = data;
if (!info->dir) if (!info->dir)
@ -1059,29 +1058,25 @@ _idler(void *data)
info->idler = NULL; info->idler = NULL;
return ECORE_CALLBACK_CANCEL; return ECORE_CALLBACK_CANCEL;
} }
dp = readdir(info->dir); if (!eina_iterator_next(info->dir, (void**) &st))
if (!dp)
{ {
free(info->curdir); free(info->curdir);
info->curdir = NULL; info->curdir = NULL;
closedir(info->dir); eina_iterator_free(info->dir);
info->dir = NULL; info->dir = NULL;
info->idler = NULL; info->idler = NULL;
_scan(info); _scan(info);
return ECORE_CALLBACK_CANCEL; return ECORE_CALLBACK_CANCEL;
} }
if ((!strcmp(dp->d_name, ".")) || (!strcmp(dp->d_name, ".."))) if ((st->path[st->name_start]) == '.')
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
if (dp->d_name[0] == '.') if (st->type == EINA_FILE_DIR)
return ECORE_CALLBACK_RENEW;
snprintf(buf, sizeof(buf), "%s/%s", info->curdir, dp->d_name);
if (ecore_file_is_dir(buf))
{ {
info->dirs = eina_list_append(info->dirs, strdup(buf)); info->dirs = eina_list_append(info->dirs, strdup(st->path));
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
info->scans++; info->scans++;
_pan_file_add(info->span, buf, 0, 0); _pan_file_add(info->span, st->path, 0, 0);
e_util_wakeup(); e_util_wakeup();
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
@ -1102,7 +1097,7 @@ _scan(Info *info)
if (info->curdir) free(info->curdir); if (info->curdir) free(info->curdir);
info->curdir = info->dirs->data; info->curdir = info->dirs->data;
info->dirs = eina_list_remove_list(info->dirs, info->dirs); info->dirs = eina_list_remove_list(info->dirs, info->dirs);
if (!info->dir) info->dir = opendir(info->curdir); if (!info->dir) info->dir = eina_file_stat_ls(info->curdir);
info->idler = ecore_idler_add(_idler, info); info->idler = ecore_idler_add(_idler, info);
} }
} }
@ -1300,7 +1295,7 @@ wp_broser_free(Info *info)
if (!info) return; if (!info) return;
e_object_del(E_OBJECT(info->win)); e_object_del(E_OBJECT(info->win));
if (info->dir) closedir(info->dir); if (info->dir) eina_iterator_free(info->dir);
free(info->bg_file); free(info->bg_file);
free(info->curdir); free(info->curdir);
EINA_LIST_FREE(info->dirs, s) EINA_LIST_FREE(info->dirs, s)

View File

@ -2815,12 +2815,12 @@ _evry_matches_update(Evry_Selector *sel, int async)
/* check if input matches plugin trigger */ /* check if input matches plugin trigger */
if (input) if (input)
{ {
int len_trigger = 0; size_t len_trigger = 0;
EINA_LIST_FOREACH (s->plugins, l, p) EINA_LIST_FOREACH (s->plugins, l, p)
{ {
if (!p->config->trigger) continue; if (!p->config->trigger) continue;
int len = strlen(p->config->trigger); size_t len = strlen(p->config->trigger);
if (len_trigger && len != len_trigger) if (len_trigger && len != len_trigger)
continue; continue;
@ -2884,7 +2884,7 @@ _evry_matches_update(Evry_Selector *sel, int async)
/* skip non-toplevel plugins when input < min_query */ /* skip non-toplevel plugins when input < min_query */
if ((!p->config->top_level) && if ((!p->config->top_level) &&
(p->config->min_query > len_inp)) ((size_t) p->config->min_query > len_inp))
goto next; goto next;
} }

View File

@ -224,9 +224,9 @@ struct _Evry_Event_Action_Performed
/* call free on all items provided by plugin instance '_p' */ /* call free on all items provided by plugin instance '_p' */
#define EVRY_PLUGIN_ITEMS_FREE(_p) { \ #define EVRY_PLUGIN_ITEMS_FREE(_p) { \
Evry_Item *it; \ Evry_Item *_it; \
EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, it) \ EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, _it) \
evry->item_free(it); } evry->item_free(_it); }
/* append '_item' to list of items provided by plugin instance '_p' */ /* append '_item' to list of items provided by plugin instance '_p' */
#define EVRY_PLUGIN_ITEM_APPEND(_p, _item) \ #define EVRY_PLUGIN_ITEM_APPEND(_p, _item) \
@ -255,9 +255,9 @@ struct _Evry_Event_Action_Performed
(_input && (strlen(_input) >= EVRY_PLUGIN(_p)->config->min_query))) (_input && (strlen(_input) >= EVRY_PLUGIN(_p)->config->min_query)))
#define EVRY_PLUGIN_ITEMS_CLEAR(_p) { \ #define EVRY_PLUGIN_ITEMS_CLEAR(_p) { \
Evry_Item *it; \ Evry_Item *_it; \
EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, it) \ EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, _it) \
if (it) it->fuzzy_match = 0; } if (_it) _it->fuzzy_match = 0; }
#define EVRY_PLUGIN_HAS_ITEMS(_p) !!(EVRY_PLUGIN(_p)->items) #define EVRY_PLUGIN_HAS_ITEMS(_p) !!(EVRY_PLUGIN(_p)->items)
@ -273,9 +273,9 @@ struct _Evry_Event_Action_Performed
_module = E_NEW(Evry_Module, 1); \ _module = E_NEW(Evry_Module, 1); \
_module->init = &_init; \ _module->init = &_init; \
_module->shutdown = &_shutdown; \ _module->shutdown = &_shutdown; \
Eina_List *l = e_datastore_get("evry_modules"); \ Eina_List *_l = e_datastore_get("evry_modules"); \
l = eina_list_append(l, _module); \ _l = eina_list_append(_l, _module); \
e_datastore_set("evry_modules", l); \ e_datastore_set("evry_modules", _l); \
if ((_evry = e_datastore_get("evry_api"))) \ if ((_evry = e_datastore_get("evry_api"))) \
_module->active = _init(_evry); \ _module->active = _init(_evry); \
} }
@ -284,9 +284,9 @@ struct _Evry_Event_Action_Performed
{ \ { \
if (_module->active) _module->shutdown(); \ if (_module->active) _module->shutdown(); \
_module->active = EINA_FALSE; \ _module->active = EINA_FALSE; \
Eina_List *l = e_datastore_get("evry_modules"); \ Eina_List *_l = e_datastore_get("evry_modules"); \
l = eina_list_remove(l, _module); \ _l = eina_list_remove(_l, _module); \
if (l) e_datastore_set("evry_modules", l); \ if (_l) e_datastore_set("evry_modules", _l); \
else e_datastore_del("evry_modules"); \ else e_datastore_del("evry_modules"); \
E_FREE(_module); \ E_FREE(_module); \
} }

View File

@ -75,7 +75,7 @@ static Eina_List *exe_path = NULL;
static Ecore_Idler *exe_scan_idler = NULL; static Ecore_Idler *exe_scan_idler = NULL;
static E_Config_DD *exelist_exe_edd = NULL; static E_Config_DD *exelist_exe_edd = NULL;
static E_Config_DD *exelist_edd = NULL; static E_Config_DD *exelist_edd = NULL;
static DIR *exe_dir = NULL; static Eina_Iterator *exe_dir = NULL;
static Eina_List *exe_list = NULL; static Eina_List *exe_list = NULL;
static Eina_List *exe_list2 = NULL; static Eina_List *exe_list2 = NULL;
static Eina_List *apps_cache = NULL; static Eina_List *apps_cache = NULL;
@ -231,7 +231,7 @@ _fetch_exe(Evry_Plugin *plugin, const char *input)
{ {
GET_PLUGIN(p, plugin); GET_PLUGIN(p, plugin);
Eina_List *l; Eina_List *l;
Evry_Item *it; Evry_Item *eit;
History_Types *ht; History_Types *ht;
unsigned int len = (input ? strlen(input) : 0); unsigned int len = (input ? strlen(input) : 0);
double max = 0.0; double max = 0.0;
@ -291,11 +291,11 @@ _fetch_exe(Evry_Plugin *plugin, const char *input)
} }
} }
EINA_LIST_FOREACH (plugin->items, l, it) EINA_LIST_FOREACH (plugin->items, l, eit)
{ {
evry->history_item_usage_set(it, input, NULL); evry->history_item_usage_set(eit, input, NULL);
if (input && (it->usage > max) && !strncmp(input, it->label, len)) if (input && (eit->usage > max) && !strncmp(input, eit->label, len))
max = it->usage; max = eit->usage;
} }
EVRY_ITEM(p->command)->usage = (max * 2.0); EVRY_ITEM(p->command)->usage = (max * 2.0);
@ -340,7 +340,7 @@ _finish_exe(Evry_Plugin *plugin)
if (exe_dir) if (exe_dir)
{ {
closedir(exe_dir); eina_iterator_free(exe_dir);
exe_dir = NULL; exe_dir = NULL;
} }
EINA_LIST_FREE (exe_path, str) EINA_LIST_FREE (exe_path, str)
@ -1439,17 +1439,12 @@ evry_plug_apps_save(void)
static Eina_Bool static Eina_Bool
_scan_idler(void *data __UNUSED__) _scan_idler(void *data __UNUSED__)
{ {
struct stat st;
struct dirent *dp;
char *dir; char *dir;
char buf[4096];
/* no more path items left - stop scanning */ /* no more path items left - stop scanning */
if (!exe_path) if (!exe_path)
{ {
Eina_List *l, *l2; Eina_List *l, *l2;
E_Exe_List *el;
E_Exe *ee;
int different = 0; int different = 0;
/* FIXME: check wheter they match or not */ /* FIXME: check wheter they match or not */
@ -1464,40 +1459,42 @@ _scan_idler(void *data __UNUSED__)
if ((l) || (l2)) different = 1; if ((l) || (l2)) different = 1;
if (exe_list2) if (exe_list2)
{ {
while (exe_list) void *tmp;
{
free(eina_list_data_get(exe_list)); EINA_LIST_FREE(exe_list, tmp)
exe_list = eina_list_remove_list(exe_list, exe_list); free(tmp);
}
exe_list = exe_list2; exe_list = exe_list2;
exe_list2 = NULL; exe_list2 = NULL;
} }
if (different) if (different)
{ {
const char *s;
E_Exe_List *el;
E_Exe *ee;
el = calloc(1, sizeof(E_Exe_List)); el = calloc(1, sizeof(E_Exe_List));
if (el) if (!el) return ECORE_CALLBACK_CANCEL;
{
el->list = NULL; el->list = NULL;
for (l = exe_list; l; l = l->next)
EINA_LIST_FOREACH(exe_list, l, s)
{ {
ee = malloc(sizeof(E_Exe)); ee = malloc(sizeof(E_Exe));
if (ee) if (!ee) continue ;
{
ee->path = eina_stringshare_add(l->data); ee->path = eina_stringshare_add(s);
el->list = eina_list_append(el->list, ee); el->list = eina_list_append(el->list, ee);
} }
}
e_config_domain_save("exebuf_exelist_cache", exelist_edd, el); e_config_domain_save("exebuf_exelist_cache", exelist_edd, el);
while (el->list)
EINA_LIST_FREE(el->list, ee)
{ {
ee = eina_list_data_get(el->list);
eina_stringshare_del(ee->path); eina_stringshare_del(ee->path);
free(ee); free(ee);
el->list = eina_list_remove_list(el->list, el->list);
} }
free(el); free(el);
} }
}
exe_scan_idler = NULL; exe_scan_idler = NULL;
return ECORE_CALLBACK_CANCEL; return ECORE_CALLBACK_CANCEL;
} }
@ -1505,28 +1502,25 @@ _scan_idler(void *data __UNUSED__)
if (!exe_dir) if (!exe_dir)
{ {
dir = exe_path->data; dir = exe_path->data;
exe_dir = opendir(dir); exe_dir = eina_file_direct_ls(dir);
} }
/* if we have an opened dir - scan the next item */ /* if we have an opened dir - scan the next item */
if (exe_dir) if (exe_dir)
{ {
dir = exe_path->data; Eina_File_Direct_Info *info;
dp = readdir(exe_dir); if (eina_iterator_next(exe_dir, (void**) &info))
if (dp)
{ {
if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, ".."))) Eina_Stat st;
{
snprintf(buf, sizeof(buf), "%s/%s", dir, dp->d_name); if (eina_file_statat(eina_iterator_container_get(exe_dir), info, &st) &&
if ((stat(buf, &st) == 0) && (!S_ISDIR(st.mode)) &&
((!S_ISDIR(st.st_mode)) && (!access(info->path, X_OK)))
(!access(buf, X_OK))))
{ {
if (!exe_list) if (!exe_list)
exe_list = eina_list_append(exe_list, strdup(dp->d_name)); exe_list = eina_list_append(exe_list, strdup(info->path + info->name_start));
else else
exe_list2 = eina_list_append(exe_list2, strdup(dp->d_name)); exe_list2 = eina_list_append(exe_list2, strdup(info->path + info->name_start));
}
} }
} }
else else
@ -1535,9 +1529,12 @@ _scan_idler(void *data __UNUSED__)
* of the path list so we advance and next loop we will pick up * of the path list so we advance and next loop we will pick up
* the next item, or if null- abort * the next item, or if null- abort
*/ */
closedir(exe_dir); dir = exe_path->data;
free(dir);
eina_iterator_free(exe_dir);
exe_dir = NULL; exe_dir = NULL;
free(eina_list_data_get(exe_path));
exe_path = eina_list_remove_list(exe_path, exe_path); exe_path = eina_list_remove_list(exe_path, exe_path);
} }
} }