Enlightenment CVS committal Author : englebass Project : e17 Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_file Modified Files: ecore_file_monitor_inotify.c Log Message: Readd watch if a file is recreated. =================================================================== RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_file/ecore_file_monitor_inotify.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- ecore_file_monitor_inotify.c 26 Mar 2007 21:47:41 -0000 1.14 +++ ecore_file_monitor_inotify.c 27 Mar 2007 05:36:29 -0000 1.15 @@ -31,8 +31,8 @@ static int _ecore_file_monitor_inotify_handler(void *data, Ecore_Fd_Handler *fdh); static Ecore_File_Monitor *_ecore_file_monitor_inotify_monitor_find(int wd); -static void _ecore_file_monitor_inotify_events(Ecore_File_Monitor *em, - char *file, int mask); +static void _ecore_file_monitor_inotify_events(Ecore_File_Monitor *em, char *file, int mask); +static int _ecore_file_monitor_inotify_monitor(Ecore_File_Monitor *em, const char *path); #if 0 static void _ecore_file_monitor_inotify_print(char *file, int mask); #endif @@ -104,16 +104,7 @@ if (ecore_file_exists(em->path)) { - int mask; - mask = IN_MODIFY| - IN_MOVED_FROM|IN_MOVED_TO| - IN_DELETE|IN_CREATE| - IN_DELETE_SELF|IN_MOVE_SELF| - IN_UNMOUNT; - ECORE_FILE_MONITOR_INOTIFY(em)->wd = inotify_add_watch(ecore_main_fd_handler_fd_get(_fdh), - em->path, - mask); - if (ECORE_FILE_MONITOR_INOTIFY(em)->wd < 0) + if (!_ecore_file_monitor_inotify_monitor(em, em->path)) { printf("inotify_add_watch error\n"); ecore_file_monitor_inotify_del(em); @@ -251,6 +242,38 @@ /* We just call delete. The dir is gone... */ em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path); } + if (mask & IN_IGNORED) + { + /* The watch is removed. If the file name still exists monitor the new one, + * else delete it */ + if (ecore_file_exists(em->path)) + { + if (!_ecore_file_monitor_inotify_monitor(em, em->path)) + em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path); + } + else + em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path); + } +} + +static int +_ecore_file_monitor_inotify_monitor(Ecore_File_Monitor *em, const char *path) +{ + int mask; + mask = IN_MODIFY| + IN_MOVED_FROM|IN_MOVED_TO| + IN_DELETE|IN_CREATE| + IN_DELETE_SELF|IN_MOVE_SELF| + IN_UNMOUNT; + ECORE_FILE_MONITOR_INOTIFY(em)->wd = inotify_add_watch(ecore_main_fd_handler_fd_get(_fdh), + path, mask); + if (ECORE_FILE_MONITOR_INOTIFY(em)->wd < 0) + { + printf("inotify_add_watch error\n"); + ecore_file_monitor_inotify_del(em); + return 0; + } + return 1; } #if 0 ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs