diff options
author | sebastid <sebastid> | 2005-03-30 06:35:12 +0000 |
---|---|---|
committer | sebastid <sebastid@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33> | 2005-03-30 06:35:12 +0000 |
commit | 40ec35d38dcbf577489f43bc3988b27914bfbdc6 (patch) | |
tree | eda2e33882f343f394581af1e7fb8d4078f916bd /legacy/ecore/src/lib/ecore_file/ecore_file_monitor.c | |
parent | 78939419b3f675f60ab1972fdf8c3a5232941115 (diff) |
Inotify monitoring almost works now. Since inotify seems to be the
future, I changed the interface of monitoring to be more like inotify.
SVN revision: 13984
Diffstat (limited to 'legacy/ecore/src/lib/ecore_file/ecore_file_monitor.c')
-rw-r--r-- | legacy/ecore/src/lib/ecore_file/ecore_file_monitor.c | 122 |
1 files changed, 119 insertions, 3 deletions
diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file_monitor.c b/legacy/ecore/src/lib/ecore_file/ecore_file_monitor.c index 0573b630fc..e270e01a63 100644 --- a/legacy/ecore/src/lib/ecore_file/ecore_file_monitor.c +++ b/legacy/ecore/src/lib/ecore_file/ecore_file_monitor.c | |||
@@ -3,8 +3,124 @@ | |||
3 | */ | 3 | */ |
4 | #include "ecore_file_private.h" | 4 | #include "ecore_file_private.h" |
5 | 5 | ||
6 | Ecore_File_Type | 6 | typedef enum { |
7 | ecore_file_monitor_type_get(Ecore_File_Monitor *em) | 7 | ECORE_FILE_MONITOR_TYPE_NONE, |
8 | #ifdef HAVE_INOTIFY | ||
9 | ECORE_FILE_MONITOR_TYPE_INOTIFY, | ||
10 | #endif | ||
11 | #ifdef HAVE_FAM | ||
12 | ECORE_FILE_MONITOR_TYPE_FAM, | ||
13 | #endif | ||
14 | #ifdef HAVE_POLL | ||
15 | ECORE_FILE_MONITOR_TYPE_POLL | ||
16 | #endif | ||
17 | } Ecore_File_Monitor_Type; | ||
18 | |||
19 | static Ecore_File_Monitor_Type monitor_type = ECORE_FILE_MONITOR_TYPE_NONE; | ||
20 | |||
21 | int | ||
22 | ecore_file_monitor_init(void) | ||
23 | { | ||
24 | #ifdef HAVE_INOTIFY | ||
25 | #if 0 | ||
26 | monitor_type = ECORE_FILE_MONITOR_TYPE_INOTIFY; | ||
27 | if (ecore_file_monitor_inotify_init()) | ||
28 | return 1; | ||
29 | #endif | ||
30 | #endif | ||
31 | #ifdef HAVE_FAM | ||
32 | #if 0 | ||
33 | monitor_type = ECORE_FILE_MONITOR_TYPE_FAM; | ||
34 | if (ecore_file_monitor_fam_init()) | ||
35 | return 1; | ||
36 | #endif | ||
37 | #endif | ||
38 | #ifdef HAVE_POLL | ||
39 | monitor_type = ECORE_FILE_MONITOR_TYPE_POLL; | ||
40 | if (ecore_file_monitor_poll_init()) | ||
41 | return 1; | ||
42 | #endif | ||
43 | monitor_type = ECORE_FILE_MONITOR_TYPE_NONE; | ||
44 | return 0; | ||
45 | } | ||
46 | |||
47 | int | ||
48 | ecore_file_monitor_shutdown(void) | ||
49 | { | ||
50 | switch (monitor_type) | ||
51 | { | ||
52 | case ECORE_FILE_MONITOR_TYPE_NONE: | ||
53 | return 1; | ||
54 | #ifdef HAVE_INOTIFY | ||
55 | case ECORE_FILE_MONITOR_TYPE_INOTIFY: | ||
56 | return ecore_file_monitor_inotify_shutdown(); | ||
57 | #endif | ||
58 | #ifdef HAVE_FAM | ||
59 | case ECORE_FILE_MONITOR_TYPE_FAM: | ||
60 | return ecore_file_monitor_fam_shutdown(); | ||
61 | #endif | ||
62 | #ifdef HAVE_POLL | ||
63 | case ECORE_FILE_MONITOR_TYPE_POLL: | ||
64 | return ecore_file_monitor_poll_shutdown(); | ||
65 | #endif | ||
66 | } | ||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | Ecore_File_Monitor * | ||
71 | ecore_file_monitor_add(const char *path, | ||
72 | void (*func) (void *data, Ecore_File_Monitor *em, | ||
73 | Ecore_File_Event event, | ||
74 | const char *path), | ||
75 | void *data) | ||
76 | { | ||
77 | switch (monitor_type) | ||
78 | { | ||
79 | case ECORE_FILE_MONITOR_TYPE_NONE: | ||
80 | return NULL; | ||
81 | #ifdef HAVE_INOTIFY | ||
82 | case ECORE_FILE_MONITOR_TYPE_INOTIFY: | ||
83 | return ecore_file_monitor_inotify_add(path, func, data); | ||
84 | #endif | ||
85 | #ifdef HAVE_FAM | ||
86 | case ECORE_FILE_MONITOR_TYPE_FAM: | ||
87 | return ecore_file_monitor_fam_add(path, func, data); | ||
88 | #endif | ||
89 | #ifdef HAVE_POLL | ||
90 | case ECORE_FILE_MONITOR_TYPE_POLL: | ||
91 | return ecore_file_monitor_poll_add(path, func, data); | ||
92 | #endif | ||
93 | } | ||
94 | return NULL; | ||
95 | } | ||
96 | |||
97 | void | ||
98 | ecore_file_monitor_del(Ecore_File_Monitor *em) | ||
99 | { | ||
100 | switch (monitor_type) | ||
101 | { | ||
102 | case ECORE_FILE_MONITOR_TYPE_NONE: | ||
103 | break; | ||
104 | #ifdef HAVE_INOTIFY | ||
105 | case ECORE_FILE_MONITOR_TYPE_INOTIFY: | ||
106 | ecore_file_monitor_inotify_del(em); | ||
107 | break; | ||
108 | #endif | ||
109 | #ifdef HAVE_FAM | ||
110 | case ECORE_FILE_MONITOR_TYPE_FAM: | ||
111 | ecore_file_monitor_fam_del(em); | ||
112 | break; | ||
113 | #endif | ||
114 | #ifdef HAVE_POLL | ||
115 | case ECORE_FILE_MONITOR_TYPE_POLL: | ||
116 | ecore_file_monitor_poll_del(em); | ||
117 | break; | ||
118 | #endif | ||
119 | } | ||
120 | } | ||
121 | |||
122 | const char * | ||
123 | ecore_file_monitor_path_get(Ecore_File_Monitor *em) | ||
8 | { | 124 | { |
9 | return em->type; | 125 | return em->path; |
10 | } | 126 | } |