From 80e3b951faa79fa05efb69056edd7a95b4061f57 Mon Sep 17 00:00:00 2001 From: Sebastian Dransfeld Date: Thu, 15 Apr 2010 19:21:23 +0000 Subject: [PATCH] efreet: listen for changes recursivly SVN revision: 48036 --- legacy/efreet/src/lib/efreet_desktop.c | 32 ++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/legacy/efreet/src/lib/efreet_desktop.c b/legacy/efreet/src/lib/efreet_desktop.c index b0d236978a..9457b8a544 100644 --- a/legacy/efreet/src/lib/efreet_desktop.c +++ b/legacy/efreet/src/lib/efreet_desktop.c @@ -12,6 +12,7 @@ #include #include #include +#include #ifdef _WIN32 # include @@ -139,6 +140,7 @@ static void efreet_desktop_update_cache_job(void *data); static int efreet_desktop_exe_cb(void *data, int type, void *event); static void efreet_desktop_changes_listen(void); +static void efreet_desktop_changes_listen_recursive(const char *path); static void efreet_desktop_changes_cb(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path); @@ -1521,11 +1523,7 @@ efreet_desktop_changes_listen(void) EINA_LIST_FREE(dirs, path) { - /* TODO: recursive */ - eina_hash_add(change_monitors, path, - ecore_file_monitor_add(path, - efreet_desktop_changes_cb, - NULL)); + efreet_desktop_changes_listen_recursive(path); eina_stringshare_del(path); } @@ -1557,6 +1555,30 @@ error: if (dirsfd > 0) close(dirsfd); } +static void +efreet_desktop_changes_listen_recursive(const char *path) +{ + char buf[PATH_MAX]; + DIR *files; + struct dirent *file; + + eina_hash_add(change_monitors, path, + ecore_file_monitor_add(path, + efreet_desktop_changes_cb, + NULL)); + + files = opendir(path); + while ((file = readdir(files))) + { + if (!file) break; + if (!strcmp(file->d_name, ".") || !strcmp(file->d_name, "..")) continue; + + snprintf(buf, sizeof(buf), "%s/%s", path, file->d_name); + if (ecore_file_is_dir(buf)) efreet_desktop_changes_listen_recursive(buf); + } + closedir(files); +} + static void efreet_desktop_changes_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__, Ecore_File_Event event, const char *path)