forked from enlightenment/efl
parent
7b41e4e522
commit
dda04c478c
|
@ -43,7 +43,7 @@ EAPI char *ecore_file_get_dir (char *path);
|
|||
|
||||
EAPI int ecore_file_can_exec (const char *file);
|
||||
EAPI char *ecore_file_readlink (const char *link);
|
||||
EAPI Evas_List *ecore_file_ls (const char *dir);
|
||||
EAPI Ecore_List *ecore_file_ls (const char *dir);
|
||||
|
||||
typedef struct _Ecore_File_Monitor Ecore_File_Monitor;
|
||||
typedef struct _Ecore_File_Monitor_Event Ecore_File_Monitor_Event;
|
||||
|
|
|
@ -183,42 +183,44 @@ ecore_file_readlink(const char *link)
|
|||
return strdup(buf);
|
||||
}
|
||||
|
||||
Evas_List *
|
||||
Ecore_List *
|
||||
ecore_file_ls(const char *dir)
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
Evas_List *list;
|
||||
Ecore_DList *list;
|
||||
|
||||
dirp = opendir(dir);
|
||||
if (!dirp) return NULL;
|
||||
list = NULL;
|
||||
list = ecore_dlist_new();
|
||||
while ((dp = readdir(dirp)))
|
||||
{
|
||||
if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, "..")))
|
||||
{
|
||||
Evas_List *l;
|
||||
char *f;
|
||||
char *file, *f;
|
||||
|
||||
/* insertion sort */
|
||||
for (l = list; l; l = l->next)
|
||||
ecore_dlist_goto_first(list);
|
||||
while ((file = ecore_dlist_next(list)))
|
||||
{
|
||||
if (strcmp(l->data, dp->d_name) > 0)
|
||||
if (strcmp(file, dp->d_name) > 0)
|
||||
{
|
||||
ecore_dlist_previous(list);
|
||||
f = strdup(dp->d_name);
|
||||
list = evas_list_prepend_relative(list, f, l->data);
|
||||
ecore_dlist_insert(list, f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* nowhwre to go? just append it */
|
||||
if (!l)
|
||||
if (!file)
|
||||
{
|
||||
f = strdup(dp->d_name);
|
||||
list = evas_list_append(list, f);
|
||||
ecore_dlist_append(list, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(dirp);
|
||||
|
||||
return list;
|
||||
ecore_dlist_goto_first(list);
|
||||
return ECORE_LIST(list);
|
||||
}
|
||||
|
|
|
@ -108,16 +108,15 @@ ecore_file_monitor_poll_add(const char *path,
|
|||
if (ecore_file_is_dir(em->path))
|
||||
{
|
||||
/* Check for subdirs */
|
||||
Evas_List *files, *l;
|
||||
Ecore_List *files;
|
||||
char *file;
|
||||
|
||||
files = ecore_file_ls(em->path);
|
||||
for (l = files; l; l = l->next)
|
||||
while ((file = ecore_list_next(files)))
|
||||
{
|
||||
Ecore_File *f;
|
||||
char *file;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
file = l->data;
|
||||
f = calloc(1, sizeof(Ecore_File));
|
||||
if (!f)
|
||||
{
|
||||
|
@ -131,7 +130,7 @@ ecore_file_monitor_poll_add(const char *path,
|
|||
f->is_dir = ecore_file_is_dir(buf);
|
||||
em->files = evas_list_append(em->files, f);
|
||||
}
|
||||
evas_list_free(files);
|
||||
ecore_list_destroy(files);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -285,18 +284,17 @@ _ecore_file_monitor_poll_check(Ecore_File_Monitor *em)
|
|||
/* Check for new files */
|
||||
if (ECORE_FILE_MONITOR_POLL(em)->mtime < mtime)
|
||||
{
|
||||
Evas_List *files;
|
||||
Ecore_List *files;
|
||||
char *file;
|
||||
|
||||
/* Files have been added or removed */
|
||||
files = ecore_file_ls(em->path);
|
||||
for (l = files; l; l = l->next)
|
||||
while ((file = ecore_list_next(files)))
|
||||
{
|
||||
Ecore_File *f;
|
||||
char *file;
|
||||
char buf[PATH_MAX];
|
||||
Ecore_File_Event event;
|
||||
|
||||
file = l->data;
|
||||
if (_ecore_file_monitor_poll_checking(em, file))
|
||||
{
|
||||
free(file);
|
||||
|
@ -321,6 +319,7 @@ _ecore_file_monitor_poll_check(Ecore_File_Monitor *em)
|
|||
em->func(em->data, em, event, buf);
|
||||
em->files = evas_list_append(em->files, f);
|
||||
}
|
||||
ecore_list_destroy(files);
|
||||
if (!ecore_file_is_dir(em->path))
|
||||
em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, em->path);
|
||||
_interval = ECORE_FILE_INTERVAL_MIN;
|
||||
|
|
Loading…
Reference in New Issue