summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac23
-rw-r--r--src/Makefile_Ecore_File.am16
-rw-r--r--src/Makefile_Eio.am2
-rw-r--r--src/lib/ecore_file/ecore_file_monitor.c104
-rw-r--r--src/lib/ecore_file/ecore_file_monitor_inotify.c19
-rw-r--r--src/lib/ecore_file/ecore_file_monitor_poll.c15
-rw-r--r--src/lib/ecore_file/ecore_file_monitor_win32.c12
-rw-r--r--src/lib/ecore_file/ecore_file_private.h45
8 files changed, 57 insertions, 179 deletions
diff --git a/configure.ac b/configure.ac
index 6dcb82a..b2069b4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -478,6 +478,13 @@ unistd.h \
478have_inotify="${ac_cv_header_sys_inotify_h}" 478have_inotify="${ac_cv_header_sys_inotify_h}"
479AM_CONDITIONAL([HAVE_INOTIFY], [test "x${have_inotify}" = "xyes"]) 479AM_CONDITIONAL([HAVE_INOTIFY], [test "x${have_inotify}" = "xyes"])
480 480
481have_notify_win32="${have_win32}"
482AC_DEFINE_IF([HAVE_NOTIFY_WIN32],
483 [test "x${have_notify_win32}" = "xyes"],
484 [File monitoring with Windows notification])
485AM_CONDITIONAL([HAVE_NOTIFY_WIN32], [test "x${have_notify_win32}" = "xyes"])
486
487
481EFL_CHECK_PATH_MAX 488EFL_CHECK_PATH_MAX
482 489
483 490
@@ -2392,17 +2399,6 @@ if test "x${want_poll}" = "xyes" ; then
2392 have_poll="yes" 2399 have_poll="yes"
2393fi 2400fi
2394 2401
2395have_notify_win32="no"
2396
2397case "$host_os" in
2398 mingw32ce*)
2399 ;;
2400 mingw32*)
2401 have_notify_win32="yes"
2402 AC_DEFINE([HAVE_NOTIFY_WIN32], [1], [File monitoring with Windows notification])
2403 ;;
2404esac
2405
2406if ! test "x${have_atfile_source}" = "xno" ; then 2402if ! test "x${have_atfile_source}" = "xno" ; then
2407 AC_CHECK_FUNCS([mkdirat], 2403 AC_CHECK_FUNCS([mkdirat],
2408 [ 2404 [
@@ -3933,11 +3929,6 @@ setxattr("/", "user.ethumb.md5", NULL, 0, 0);
3933 3929
3934AC_MSG_RESULT([${have_xattr}]) 3930AC_MSG_RESULT([${have_xattr}])
3935 3931
3936# Check for inotify specificity
3937have_notify_win32="no"
3938EIO_CHECK_NOTIFY_WIN32([have_notify_win32="yes"], [have_notify_win32="no"])
3939AM_CONDITIONAL([EIO_HAVE_WINCHANGE], [test "x${have_notify_win32}" = "xyes"])
3940
3941#### End of Eio 3932#### End of Eio
3942 3933
3943 3934
diff --git a/src/Makefile_Ecore_File.am b/src/Makefile_Ecore_File.am
index 2172245..4f0f150 100644
--- a/src/Makefile_Ecore_File.am
+++ b/src/Makefile_Ecore_File.am
@@ -11,12 +11,22 @@ lib_ecore_file_libecore_file_la_SOURCES = \
11lib/ecore_file/ecore_file.c \ 11lib/ecore_file/ecore_file.c \
12lib/ecore_file/ecore_file_download.c \ 12lib/ecore_file/ecore_file_download.c \
13lib/ecore_file/ecore_file_monitor.c \ 13lib/ecore_file/ecore_file_monitor.c \
14lib/ecore_file/ecore_file_monitor_inotify.c \
15lib/ecore_file/ecore_file_monitor_poll.c \
16lib/ecore_file/ecore_file_monitor_win32.c \
17lib/ecore_file/ecore_file_path.c \ 14lib/ecore_file/ecore_file_path.c \
18lib/ecore_file/ecore_file_private.h 15lib/ecore_file/ecore_file_private.h
19 16
17if HAVE_INOTIFY
18lib_ecore_file_libecore_file_la_SOURCES += \
19lib/ecore_file/ecore_file_monitor_inotify.c
20else
21if HAVE_NOTIFY_WIN32
22lib_ecore_file_libecore_file_la_SOURCES += \
23lib/ecore_file/ecore_file_monitor_win32.c
24else
25lib_ecore_file_libecore_file_la_SOURCES += \
26lib/ecore_file/ecore_file_monitor_poll.c
27endif
28endif
29
20lib_ecore_file_libecore_file_la_CPPFLAGS = \ 30lib_ecore_file_libecore_file_la_CPPFLAGS = \
21-I$(top_srcdir)/src/lib/eina \ 31-I$(top_srcdir)/src/lib/eina \
22-I$(top_srcdir)/src/lib/eo \ 32-I$(top_srcdir)/src/lib/eo \
diff --git a/src/Makefile_Eio.am b/src/Makefile_Eio.am
index 9624285..626756f 100644
--- a/src/Makefile_Eio.am
+++ b/src/Makefile_Eio.am
@@ -21,7 +21,7 @@ lib/eio/eio_private.h
21if HAVE_INOTIFY 21if HAVE_INOTIFY
22lib_eio_libeio_la_SOURCES += lib/eio/eio_monitor_inotify.c 22lib_eio_libeio_la_SOURCES += lib/eio/eio_monitor_inotify.c
23else 23else
24if EIO_HAVE_WINCHANGE 24if HAVE_NOTIFY_WIN32
25lib_eio_libeio_la_SOURCES += lib/eio/eio_monitor_win32.c 25lib_eio_libeio_la_SOURCES += lib/eio/eio_monitor_win32.c
26endif 26endif
27endif 27endif
diff --git a/src/lib/ecore_file/ecore_file_monitor.c b/src/lib/ecore_file/ecore_file_monitor.c
index ac7d6d4..6b6fb32 100644
--- a/src/lib/ecore_file/ecore_file_monitor.c
+++ b/src/lib/ecore_file/ecore_file_monitor.c
@@ -4,66 +4,18 @@
4 4
5#include "ecore_file_private.h" 5#include "ecore_file_private.h"
6 6
7typedef enum {
8 ECORE_FILE_MONITOR_TYPE_NONE,
9#ifdef HAVE_SYS_INOTIFY_H
10 ECORE_FILE_MONITOR_TYPE_INOTIFY,
11#endif
12#ifdef HAVE_NOTIFY_WIN32
13 ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32,
14#endif
15#ifdef HAVE_POLL
16 ECORE_FILE_MONITOR_TYPE_POLL
17#endif
18} Ecore_File_Monitor_Type;
19
20static Ecore_File_Monitor_Type monitor_type = ECORE_FILE_MONITOR_TYPE_NONE;
21
22int 7int
23ecore_file_monitor_init(void) 8ecore_file_monitor_init(void)
24{ 9{
25#ifdef HAVE_SYS_INOTIFY_H 10 if (ecore_file_monitor_backend_init())
26 monitor_type = ECORE_FILE_MONITOR_TYPE_INOTIFY;
27 if (ecore_file_monitor_inotify_init())
28 return 1; 11 return 1;
29#endif
30#ifdef HAVE_NOTIFY_WIN32
31 monitor_type = ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32;
32 if (ecore_file_monitor_win32_init())
33 return 1;
34#endif
35#ifdef HAVE_POLL
36 monitor_type = ECORE_FILE_MONITOR_TYPE_POLL;
37 if (ecore_file_monitor_poll_init())
38 return 1;
39#endif
40 monitor_type = ECORE_FILE_MONITOR_TYPE_NONE;
41 return 0; 12 return 0;
42} 13}
43 14
44void 15void
45ecore_file_monitor_shutdown(void) 16ecore_file_monitor_shutdown(void)
46{ 17{
47 switch (monitor_type) 18 ecore_file_monitor_backend_shutdown();
48 {
49 case ECORE_FILE_MONITOR_TYPE_NONE:
50 break;
51#ifdef HAVE_SYS_INOTIFY_H
52 case ECORE_FILE_MONITOR_TYPE_INOTIFY:
53 ecore_file_monitor_inotify_shutdown();
54 break;
55#endif
56#ifdef HAVE_NOTIFY_WIN32
57 case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32:
58 ecore_file_monitor_win32_shutdown();
59 break;
60#endif
61#ifdef HAVE_POLL
62 case ECORE_FILE_MONITOR_TYPE_POLL:
63 ecore_file_monitor_poll_shutdown();
64 break;
65#endif
66 }
67} 19}
68 20
69/** 21/**
@@ -94,27 +46,11 @@ ecore_file_monitor_add(const char *path,
94 Ecore_File_Monitor_Cb func, 46 Ecore_File_Monitor_Cb func,
95 void *data) 47 void *data)
96{ 48{
97 if (!path || !*path) 49 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
98 return NULL; 50 EINA_SAFETY_ON_TRUE_RETURN_VAL(path[0] == '\0', NULL);
51 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
99 52
100 switch (monitor_type) 53 return ecore_file_monitor_backend_add(path, func, data);
101 {
102 case ECORE_FILE_MONITOR_TYPE_NONE:
103 return NULL;
104#ifdef HAVE_SYS_INOTIFY_H
105 case ECORE_FILE_MONITOR_TYPE_INOTIFY:
106 return ecore_file_monitor_inotify_add(path, func, data);
107#endif
108#ifdef HAVE_NOTIFY_WIN32
109 case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32:
110 return ecore_file_monitor_win32_add(path, func, data);
111#endif
112#ifdef HAVE_POLL
113 case ECORE_FILE_MONITOR_TYPE_POLL:
114 return ecore_file_monitor_poll_add(path, func, data);
115#endif
116 }
117 return NULL;
118} 54}
119 55
120/** 56/**
@@ -131,29 +67,8 @@ ecore_file_monitor_add(const char *path,
131EAPI void 67EAPI void
132ecore_file_monitor_del(Ecore_File_Monitor *em) 68ecore_file_monitor_del(Ecore_File_Monitor *em)
133{ 69{
134 if (!em) 70 EINA_SAFETY_ON_NULL_RETURN(em);
135 return; 71 ecore_file_monitor_backend_del(em);
136
137 switch (monitor_type)
138 {
139 case ECORE_FILE_MONITOR_TYPE_NONE:
140 break;
141#ifdef HAVE_SYS_INOTIFY_H
142 case ECORE_FILE_MONITOR_TYPE_INOTIFY:
143 ecore_file_monitor_inotify_del(em);
144 break;
145#endif
146#ifdef HAVE_NOTIFY_WIN32
147 case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32:
148 ecore_file_monitor_win32_del(em);
149 break;
150#endif
151#ifdef HAVE_POLL
152 case ECORE_FILE_MONITOR_TYPE_POLL:
153 ecore_file_monitor_poll_del(em);
154 break;
155#endif
156 }
157} 72}
158 73
159/** 74/**
@@ -170,8 +85,7 @@ ecore_file_monitor_del(Ecore_File_Monitor *em)
170EAPI const char * 85EAPI const char *
171ecore_file_monitor_path_get(Ecore_File_Monitor *em) 86ecore_file_monitor_path_get(Ecore_File_Monitor *em)
172{ 87{
173 if (!em) 88 EINA_SAFETY_ON_NULL_RETURN_VAL(em, NULL);
174 return NULL;
175 return em->path; 89 return em->path;
176} 90}
177 91
diff --git a/src/lib/ecore_file/ecore_file_monitor_inotify.c b/src/lib/ecore_file/ecore_file_monitor_inotify.c
index 9cb5de8..9f9818d 100644
--- a/src/lib/ecore_file/ecore_file_monitor_inotify.c
+++ b/src/lib/ecore_file/ecore_file_monitor_inotify.c
@@ -20,8 +20,6 @@
20 * - Listen to IN_IGNORED, emitted when the watch is removed 20 * - Listen to IN_IGNORED, emitted when the watch is removed
21 */ 21 */
22 22
23#ifdef HAVE_SYS_INOTIFY_H
24
25#include <sys/inotify.h> 23#include <sys/inotify.h>
26 24
27 25
@@ -48,7 +46,7 @@ static void _ecore_file_monitor_inotify_print(char *file, int mas
48#endif 46#endif
49 47
50int 48int
51ecore_file_monitor_inotify_init(void) 49ecore_file_monitor_backend_init(void)
52{ 50{
53 int fd; 51 int fd;
54 52
@@ -69,12 +67,12 @@ ecore_file_monitor_inotify_init(void)
69} 67}
70 68
71int 69int
72ecore_file_monitor_inotify_shutdown(void) 70ecore_file_monitor_backend_shutdown(void)
73{ 71{
74 int fd; 72 int fd;
75 73
76 while(_monitors) 74 while(_monitors)
77 ecore_file_monitor_inotify_del(_monitors); 75 ecore_file_monitor_backend_del(_monitors);
78 76
79 if (_fdh) 77 if (_fdh)
80 { 78 {
@@ -87,7 +85,7 @@ ecore_file_monitor_inotify_shutdown(void)
87} 85}
88 86
89Ecore_File_Monitor * 87Ecore_File_Monitor *
90ecore_file_monitor_inotify_add(const char *path, 88ecore_file_monitor_backend_add(const char *path,
91 void (*func) (void *data, Ecore_File_Monitor *em, 89 void (*func) (void *data, Ecore_File_Monitor *em,
92 Ecore_File_Event event, 90 Ecore_File_Event event,
93 const char *path), 91 const char *path),
@@ -100,8 +98,8 @@ ecore_file_monitor_inotify_add(const char *path,
100 98
101 if (_inotify_fd_pid != getpid()) 99 if (_inotify_fd_pid != getpid())
102 { 100 {
103 ecore_file_monitor_inotify_shutdown(); 101 ecore_file_monitor_backend_shutdown();
104 ecore_file_monitor_inotify_init(); 102 ecore_file_monitor_backend_init();
105 } 103 }
106 104
107 em = calloc(1, sizeof(Ecore_File_Monitor_Inotify)); 105 em = calloc(1, sizeof(Ecore_File_Monitor_Inotify));
@@ -124,7 +122,7 @@ ecore_file_monitor_inotify_add(const char *path,
124} 122}
125 123
126void 124void
127ecore_file_monitor_inotify_del(Ecore_File_Monitor *em) 125ecore_file_monitor_backend_del(Ecore_File_Monitor *em)
128{ 126{
129 int fd; 127 int fd;
130 128
@@ -283,7 +281,7 @@ _ecore_file_monitor_inotify_monitor(Ecore_File_Monitor *em, const char *path)
283 if (ECORE_FILE_MONITOR_INOTIFY(em)->wd < 0) 281 if (ECORE_FILE_MONITOR_INOTIFY(em)->wd < 0)
284 { 282 {
285 INF("inotify_add_watch failed, file was deleted"); 283 INF("inotify_add_watch failed, file was deleted");
286 ecore_file_monitor_inotify_del(em); 284 ecore_file_monitor_backend_del(em);
287 return 0; 285 return 0;
288 } 286 }
289 return 1; 287 return 1;
@@ -328,4 +326,3 @@ _ecore_file_monitor_inotify_print(char *file, int mask)
328 INF("Inotify unmount %s: %s", type, file); 326 INF("Inotify unmount %s: %s", type, file);
329} 327}
330#endif 328#endif
331#endif /* HAVE_SYS_INOTIFY_H */
diff --git a/src/lib/ecore_file/ecore_file_monitor_poll.c b/src/lib/ecore_file/ecore_file_monitor_poll.c
index 68889a7..03ac117 100644
--- a/src/lib/ecore_file/ecore_file_monitor_poll.c
+++ b/src/lib/ecore_file/ecore_file_monitor_poll.c
@@ -8,8 +8,6 @@
8 8
9#include "ecore_file_private.h" 9#include "ecore_file_private.h"
10 10
11#ifdef HAVE_POLL
12
13/* 11/*
14 * TODO: 12 * TODO:
15 * - Implement recursive as an option! 13 * - Implement recursive as an option!
@@ -43,16 +41,16 @@ static void _ecore_file_monitor_poll_check(Ecore_File_Monitor *em);
43static int _ecore_file_monitor_poll_checking(Ecore_File_Monitor *em, char *name); 41static int _ecore_file_monitor_poll_checking(Ecore_File_Monitor *em, char *name);
44 42
45int 43int
46ecore_file_monitor_poll_init(void) 44ecore_file_monitor_backend_init(void)
47{ 45{
48 return 1; 46 return 1;
49} 47}
50 48
51int 49int
52ecore_file_monitor_poll_shutdown(void) 50ecore_file_monitor_backend_shutdown(void)
53{ 51{
54 while(_monitors) 52 while(_monitors)
55 ecore_file_monitor_poll_del(_monitors); 53 ecore_file_monitor_backend_del(_monitors);
56 54
57 if (_timer) 55 if (_timer)
58 { 56 {
@@ -63,7 +61,7 @@ ecore_file_monitor_poll_shutdown(void)
63} 61}
64 62
65Ecore_File_Monitor * 63Ecore_File_Monitor *
66ecore_file_monitor_poll_add(const char *path, 64ecore_file_monitor_backend_add(const char *path,
67 void (*func) (void *data, Ecore_File_Monitor *em, 65 void (*func) (void *data, Ecore_File_Monitor *em,
68 Ecore_File_Event event, 66 Ecore_File_Event event,
69 const char *path), 67 const char *path),
@@ -125,7 +123,7 @@ ecore_file_monitor_poll_add(const char *path,
125 } 123 }
126 else 124 else
127 { 125 {
128 ecore_file_monitor_poll_del(em); 126 ecore_file_monitor_backend_del(em);
129 return NULL; 127 return NULL;
130 } 128 }
131 129
@@ -133,7 +131,7 @@ ecore_file_monitor_poll_add(const char *path,
133} 131}
134 132
135void 133void
136ecore_file_monitor_poll_del(Ecore_File_Monitor *em) 134ecore_file_monitor_backend_del(Ecore_File_Monitor *em)
137{ 135{
138 Ecore_File *l; 136 Ecore_File *l;
139 137
@@ -337,4 +335,3 @@ _ecore_file_monitor_poll_checking(Ecore_File_Monitor *em, char *name)
337 } 335 }
338 return 0; 336 return 0;
339} 337}
340#endif
diff --git a/src/lib/ecore_file/ecore_file_monitor_win32.c b/src/lib/ecore_file/ecore_file_monitor_win32.c
index 7f3af09..84ac083 100644
--- a/src/lib/ecore_file/ecore_file_monitor_win32.c
+++ b/src/lib/ecore_file/ecore_file_monitor_win32.c
@@ -6,8 +6,6 @@
6# include <config.h> 6# include <config.h>
7#endif 7#endif
8 8
9#ifdef HAVE_NOTIFY_WIN32
10
11# define WIN32_LEAN_AND_MEAN 9# define WIN32_LEAN_AND_MEAN
12# include <windows.h> 10# include <windows.h>
13# undef WIN32_LEAN_AND_MEAN 11# undef WIN32_LEAN_AND_MEAN
@@ -225,19 +223,19 @@ _ecore_file_monitor_win32_cb(void *data, Ecore_Win32_Handler *wh)
225} 223}
226 224
227int 225int
228ecore_file_monitor_win32_init(void) 226ecore_file_monitor_backend_init(void)
229{ 227{
230 return 1; 228 return 1;
231} 229}
232 230
233int 231int
234ecore_file_monitor_win32_shutdown(void) 232ecore_file_monitor_backend_shutdown(void)
235{ 233{
236 return 1; 234 return 1;
237} 235}
238 236
239Ecore_File_Monitor * 237Ecore_File_Monitor *
240ecore_file_monitor_win32_add(const char *path, 238ecore_file_monitor_backend_add(const char *path,
241 void (*func) (void *data, Ecore_File_Monitor *em, 239 void (*func) (void *data, Ecore_File_Monitor *em,
242 Ecore_File_Event event, 240 Ecore_File_Event event,
243 const char *path), 241 const char *path),
@@ -293,7 +291,7 @@ ecore_file_monitor_win32_add(const char *path,
293} 291}
294 292
295void 293void
296ecore_file_monitor_win32_del(Ecore_File_Monitor *em) 294ecore_file_monitor_backend_del(Ecore_File_Monitor *em)
297{ 295{
298 Ecore_File_Monitor_Win32 *m; 296 Ecore_File_Monitor_Win32 *m;
299 297
@@ -306,5 +304,3 @@ ecore_file_monitor_win32_del(Ecore_File_Monitor *em)
306 free(em->path); 304 free(em->path);
307 free(em); 305 free(em);
308} 306}
309
310#endif
diff --git a/src/lib/ecore_file/ecore_file_private.h b/src/lib/ecore_file/ecore_file_private.h
index 769f2ba..5a091b3 100644
--- a/src/lib/ecore_file/ecore_file_private.h
+++ b/src/lib/ecore_file/ecore_file_private.h
@@ -81,42 +81,15 @@ struct _Ecore_File_Monitor
81 Ecore_File *files; 81 Ecore_File *files;
82}; 82};
83 83
84#ifdef HAVE_SYS_INOTIFY_H 84int ecore_file_monitor_backend_init(void);
85int ecore_file_monitor_inotify_init(void); 85int ecore_file_monitor_backend_shutdown(void);
86int ecore_file_monitor_inotify_shutdown(void); 86Ecore_File_Monitor *ecore_file_monitor_backend_add(const char *path,
87Ecore_File_Monitor *ecore_file_monitor_inotify_add(const char *path, 87 void (*func) (void *data,
88 void (*func) (void *data, 88 Ecore_File_Monitor *ecore_file_monitor,
89 Ecore_File_Monitor *ecore_file_monitor, 89 Ecore_File_Event event,
90 Ecore_File_Event event, 90 const char *path),
91 const char *path), 91 void *data);
92 void *data); 92void ecore_file_monitor_backend_del(Ecore_File_Monitor *ecore_file_monitor);
93void ecore_file_monitor_inotify_del(Ecore_File_Monitor *ecore_file_monitor);
94#endif
95
96#ifdef HAVE_NOTIFY_WIN32
97int ecore_file_monitor_win32_init(void);
98int ecore_file_monitor_win32_shutdown(void);
99Ecore_File_Monitor *ecore_file_monitor_win32_add(const char *path,
100 void (*func) (void *data,
101 Ecore_File_Monitor *ecore_file_monitor,
102 Ecore_File_Event event,
103 const char *path),
104 void *data);
105void ecore_file_monitor_win32_del(Ecore_File_Monitor *ecore_file_monitor);
106#endif
107
108#ifdef HAVE_POLL
109int ecore_file_monitor_poll_init(void);
110int ecore_file_monitor_poll_shutdown(void);
111Ecore_File_Monitor *ecore_file_monitor_poll_add(const char *path,
112 void (*func) (void *data,
113 Ecore_File_Monitor *ecore_file_monitor,
114 Ecore_File_Event event,
115 const char *path),
116 void *data);
117void ecore_file_monitor_poll_del(Ecore_File_Monitor *ecore_file_monitor);
118
119#endif
120 93
121/* ecore_file_path */ 94/* ecore_file_path */
122void ecore_file_path_init(void); 95void ecore_file_path_init(void);