2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
9 #include "ecore_file_private.h"
14 ECORE_FILE_MONITOR_TYPE_NONE,
16 ECORE_FILE_MONITOR_TYPE_INOTIFY,
19 ECORE_FILE_MONITOR_TYPE_POLL
21 } Ecore_File_Monitor_Type;
23 static Ecore_File_Monitor_Type monitor_type = ECORE_FILE_MONITOR_TYPE_NONE;
26 ecore_file_monitor_init(void)
28 if (++init != 1) return init;
31 monitor_type = ECORE_FILE_MONITOR_TYPE_INOTIFY;
32 if (ecore_file_monitor_inotify_init())
36 monitor_type = ECORE_FILE_MONITOR_TYPE_POLL;
37 if (ecore_file_monitor_poll_init())
40 monitor_type = ECORE_FILE_MONITOR_TYPE_NONE;
45 ecore_file_monitor_shutdown(void)
47 if (--init != 0) return init;
51 case ECORE_FILE_MONITOR_TYPE_NONE:
54 case ECORE_FILE_MONITOR_TYPE_INOTIFY:
55 ecore_file_monitor_inotify_shutdown();
59 case ECORE_FILE_MONITOR_TYPE_POLL:
60 ecore_file_monitor_poll_shutdown();
68 * Monitor a path using inotify or polling
69 * @param path The path to monitor
70 * @param func The function to call on changes
71 * @param data The data passed to func
72 * @return An Ecore_File_Monitor pointer or NULL on failure
74 EAPI Ecore_File_Monitor *
75 ecore_file_monitor_add(const char *path,
76 void (*func) (void *data, Ecore_File_Monitor *em,
77 Ecore_File_Event event,
83 case ECORE_FILE_MONITOR_TYPE_NONE:
86 case ECORE_FILE_MONITOR_TYPE_INOTIFY:
87 return ecore_file_monitor_inotify_add(path, func, data);
90 case ECORE_FILE_MONITOR_TYPE_POLL:
91 return ecore_file_monitor_poll_add(path, func, data);
98 * Stop monitoring a path
99 * @param em The Ecore_File_Monitor to stop
102 ecore_file_monitor_del(Ecore_File_Monitor *em)
104 switch (monitor_type)
106 case ECORE_FILE_MONITOR_TYPE_NONE:
109 case ECORE_FILE_MONITOR_TYPE_INOTIFY:
110 ecore_file_monitor_inotify_del(em);
114 case ECORE_FILE_MONITOR_TYPE_POLL:
115 ecore_file_monitor_poll_del(em);
122 * Get the monitored path
123 * @param em The Ecore_File_Monitor to query
124 * @return The path that is monitored by @p em
127 ecore_file_monitor_path_get(Ecore_File_Monitor *em)