summaryrefslogtreecommitdiff
path: root/src/lib/ecore_file/ecore_file_monitor.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2012-12-06 13:38:34 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2012-12-06 13:38:34 +0000
commit62bb4646c9fee3f535c3810a7cdba114043d14d4 (patch)
treefad3ac78c2163cb5ebebb916c5ca52e3ed5f4ef0 /src/lib/ecore_file/ecore_file_monitor.c
parent6a5eaacc6ada22808ec8515ef2b414883f4f59fe (diff)
efl/ecore_file: refactor to be more like eio in providing backends.
instead of the previous mess, just define the functions with common names and call the backend that was compiled in, similar to what eio does. also do not be silent on errors, use eina_safety_checks to issue warnings. SVN revision: 80360
Diffstat (limited to 'src/lib/ecore_file/ecore_file_monitor.c')
-rw-r--r--src/lib/ecore_file/ecore_file_monitor.c104
1 files changed, 9 insertions, 95 deletions
diff --git a/src/lib/ecore_file/ecore_file_monitor.c b/src/lib/ecore_file/ecore_file_monitor.c
index ac7d6d4dc3..6b6fb32349 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