summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlastair Poole <mail@alastairpoole.com>2021-11-25 19:20:49 +0000
committerAlastair Poole <mail@alastairpoole.com>2021-11-25 19:20:49 +0000
commit43108e772a95d98fdd48f43a4fe707d7995e18b2 (patch)
treefc29e1f3f273f2c0a4d92f540e69ab7a7b2039b8
parent9ba7c3667ca4875e482b542be363aafd5ddc8088 (diff)
ecore_file: Monitor file writes (kevent).
Trigger ECORE_FILE_EVENT_MODIFIED on file write. @fix
-rw-r--r--src/lib/ecore_file/ecore_file_monitor_kevent.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/lib/ecore_file/ecore_file_monitor_kevent.c b/src/lib/ecore_file/ecore_file_monitor_kevent.c
index e8c4c1e238..9c5ad66c4e 100644
--- a/src/lib/ecore_file/ecore_file_monitor_kevent.c
+++ b/src/lib/ecore_file/ecore_file_monitor_kevent.c
@@ -121,7 +121,6 @@ _ecore_file_monitor_kevent_ls(const char *directory)
121 121
122 it = eina_file_direct_ls(directory); 122 it = eina_file_direct_ls(directory);
123 if (!it) return NULL; 123 if (!it) return NULL;
124
125 EINA_ITERATOR_FOREACH(it, info) 124 EINA_ITERATOR_FOREACH(it, info)
126 { 125 {
127 File_Info *file = malloc(sizeof(File_Info)); 126 File_Info *file = malloc(sizeof(File_Info));
@@ -191,7 +190,10 @@ _ecore_file_monitor_kevent_handler(void *data EINA_UNUSED, Ecore_Fd_Handler *fdh
191 } 190 }
192 if ((evs[i].fflags & NOTE_WRITE) || (evs[i].fflags & NOTE_ATTRIB)) 191 if ((evs[i].fflags & NOTE_WRITE) || (evs[i].fflags & NOTE_ATTRIB))
193 { 192 {
194 _ecore_file_monitor_kevent_find(em); 193 if (ecore_file_is_dir(em->path))
194 _ecore_file_monitor_kevent_find(em);
195 else
196 em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, em->path);
195 } 197 }
196 } 198 }
197 199
@@ -206,7 +208,6 @@ _ecore_file_monitor_kevent_find(Ecore_File_Monitor *em)
206 Eina_List *files; 208 Eina_List *files;
207 209
208 files = _ecore_file_monitor_kevent_ls(em->path); 210 files = _ecore_file_monitor_kevent_ls(em->path);
209
210 EINA_LIST_FOREACH(ECORE_FILE_MONITOR_KEVENT(em)->prev, l, file) 211 EINA_LIST_FOREACH(ECORE_FILE_MONITOR_KEVENT(em)->prev, l, file)
211 { 212 {
212 Eina_Bool exists = EINA_FALSE; 213 Eina_Bool exists = EINA_FALSE;
@@ -262,7 +263,7 @@ _ecore_file_monitor_kevent_monitor(Ecore_File_Monitor *em, const char *path)
262 struct kevent ev; 263 struct kevent ev;
263 int fd, res = 0; 264 int fd, res = 0;
264 265
265 if ((!ecore_file_exists(path)) || (!ecore_file_is_dir(path))) 266 if (!ecore_file_exists(path))
266 return 0; 267 return 0;
267 268
268 fd = open(path, O_RDONLY); 269 fd = open(path, O_RDONLY);
@@ -276,7 +277,8 @@ _ecore_file_monitor_kevent_monitor(Ecore_File_Monitor *em, const char *path)
276 eina_file_close_on_exec(fd, EINA_TRUE); 277 eina_file_close_on_exec(fd, EINA_TRUE);
277 278
278 ECORE_FILE_MONITOR_KEVENT(em)->fd = fd; 279 ECORE_FILE_MONITOR_KEVENT(em)->fd = fd;
279 ECORE_FILE_MONITOR_KEVENT(em)->prev = _ecore_file_monitor_kevent_ls(em->path); 280 if (ecore_file_is_dir(em->path))
281 ECORE_FILE_MONITOR_KEVENT(em)->prev = _ecore_file_monitor_kevent_ls(em->path);
280 282
281 eina_hash_direct_add(_kevent_monitors, &(ECORE_FILE_MONITOR_KEVENT(em)->fd), em); 283 eina_hash_direct_add(_kevent_monitors, &(ECORE_FILE_MONITOR_KEVENT(em)->fd), em);
282 284