5 #include "ecore_file_private.h"
8 ECORE_FILE_MONITOR_TYPE_NONE,
10 ECORE_FILE_MONITOR_TYPE_INOTIFY,
12 #ifdef HAVE_NOTIFY_WIN32
13 ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32,
16 ECORE_FILE_MONITOR_TYPE_POLL
18 } Ecore_File_Monitor_Type;
20 static Ecore_File_Monitor_Type monitor_type = ECORE_FILE_MONITOR_TYPE_NONE;
23 ecore_file_monitor_init(void)
26 monitor_type = ECORE_FILE_MONITOR_TYPE_INOTIFY;
27 if (ecore_file_monitor_inotify_init())
30 #ifdef HAVE_NOTIFY_WIN32
31 monitor_type = ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32;
32 if (ecore_file_monitor_win32_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)
49 case ECORE_FILE_MONITOR_TYPE_NONE:
52 case ECORE_FILE_MONITOR_TYPE_INOTIFY:
53 ecore_file_monitor_inotify_shutdown();
56 #ifdef HAVE_NOTIFY_WIN32
57 case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32:
58 ecore_file_monitor_win32_shutdown();
62 case ECORE_FILE_MONITOR_TYPE_POLL:
63 ecore_file_monitor_poll_shutdown();
70 * @addtogroup Ecore_File_Group Ecore_File - Files and direcotries convenience functions
76 * @brief Monitor the given path using inotify, Windows notification, or polling.
78 * @param path The path to monitor.
79 * @param func The function to call on changes.
80 * @param data The data passed to func.
81 * @return An Ecore_File_Monitor pointer or NULL on failure.
83 * This function monitors @p path. If @p path is @c NULL, or is an
84 * empty string, or none of the notify methods (Inotify, Windows
85 * notification or polling) is available, or if @p path is not a file,
86 * the function returns @c NULL. Otherwise, it returns a newly
87 * allocated Ecore_File_Monitor object and the monitoring begins. When
88 * one of the #Ecore_File_Event event is notified, @p func is called
89 * and @p data is passed to @p func. Call ecore_file_monitor_del() to
90 * stop the monitoring.
92 EAPI Ecore_File_Monitor *
93 ecore_file_monitor_add(const char *path,
94 Ecore_File_Monitor_Cb func,
100 switch (monitor_type)
102 case ECORE_FILE_MONITOR_TYPE_NONE:
105 case ECORE_FILE_MONITOR_TYPE_INOTIFY:
106 return ecore_file_monitor_inotify_add(path, func, data);
108 #ifdef HAVE_NOTIFY_WIN32
109 case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32:
110 return ecore_file_monitor_win32_add(path, func, data);
113 case ECORE_FILE_MONITOR_TYPE_POLL:
114 return ecore_file_monitor_poll_add(path, func, data);
121 * @brief Stop the monitoring of the given path.
123 * @param em The Ecore_File_Monitor to stop.
125 * This function stops the the monitoring of the path that has been
126 * monitored by ecore_file_monitor_add(). @p em must be the value
127 * returned by ecore_file_monitor_add(). If @p em is @c NULL, or none
128 * of the notify methods (Inotify, Windows notification or polling) is
129 * availablethis function does nothing.
132 ecore_file_monitor_del(Ecore_File_Monitor *em)
137 switch (monitor_type)
139 case ECORE_FILE_MONITOR_TYPE_NONE:
142 case ECORE_FILE_MONITOR_TYPE_INOTIFY:
143 ecore_file_monitor_inotify_del(em);
146 #ifdef HAVE_NOTIFY_WIN32
147 case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32:
148 ecore_file_monitor_win32_del(em);
152 case ECORE_FILE_MONITOR_TYPE_POLL:
153 ecore_file_monitor_poll_del(em);
160 * @brief Get the monitored path.
162 * @param em The Ecore_File_Monitor to query.
163 * @return The path that is monitored by @p em.
165 * This function returns the monitored path that has been
166 * monitored by ecore_file_monitor_add(). @p em must be the value
167 * returned by ecore_file_monitor_add(). If @p em is @c NULL, the
168 * function returns @c NULL.
171 ecore_file_monitor_path_get(Ecore_File_Monitor *em)