pepper-inotify: provide a path information to inotify event 01/207201/1
authorjeon <jhyuni.kang@samsung.com>
Mon, 20 May 2019 08:28:35 +0000 (17:28 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 30 May 2019 08:34:53 +0000 (17:34 +0900)
Change-Id: I14f001668c885e81dbf4dffc2217c15fe1f7cbaf

src/lib/inotify/pepper-inotify-internal.h
src/lib/inotify/pepper-inotify.c
src/lib/inotify/pepper-inotify.h

index 56f3f83..3ebc3a6 100644 (file)
@@ -34,6 +34,7 @@ struct pepper_inotify_event
        pepper_inotify_t *inotify;
 
        char *name;
+       char *path;
        pepper_bool_t is_dir;
 };
 
index 6960dd0..56ff285 100644 (file)
 #include <pepper-inotify-internal.h>
 
 static void
-_inotify_event_post(pepper_inotify_t *inotify, pepper_inotify_event_type_t type, const char *name, pepper_bool_t is_dir)
+_inotify_event_post(pepper_inotify_watch_t *watch, pepper_inotify_event_type_t type, const char *name, pepper_bool_t is_dir)
 {
        pepper_inotify_event_t ev;
 
-       PEPPER_CHECK(inotify->callback.cb, return, "Current inotify has no callback");
+       PEPPER_CHECK(watch->inotify->callback.cb, return, "Current inotify has no callback");
 
-       ev.inotify = inotify;
+       ev.inotify = watch->inotify;
 
        ev.name = (char *)name;
        ev.is_dir = is_dir;
+       ev.path = watch->path;
 
-       inotify->callback.cb(type, &ev, inotify->callback.data);
+       watch->inotify->callback.cb(type, &ev, watch->inotify->callback.data);
 }
 
 static void
@@ -59,15 +60,15 @@ _inotify_event_process(struct inotify_event *ev, pepper_inotify_watch_t *watch)
        if (!ev->len) return;
 
        if (ev->mask & IN_CREATE) {
-               _inotify_event_post(watch->inotify, PEPPER_INOTIFY_EVENT_TYPE_CREATE,
+               _inotify_event_post(watch, PEPPER_INOTIFY_EVENT_TYPE_CREATE,
                                        ev->name, (ev->mask & IN_ISDIR) ? PEPPER_TRUE : PEPPER_FALSE);
        }
        else if (ev->mask & IN_DELETE) {
-               _inotify_event_post(watch->inotify, PEPPER_INOTIFY_EVENT_TYPE_REMOVE,
+               _inotify_event_post(watch, PEPPER_INOTIFY_EVENT_TYPE_REMOVE,
                                        ev->name, (ev->mask & IN_ISDIR) ? PEPPER_TRUE : PEPPER_FALSE);
        }
        else if (ev->mask & IN_MODIFY) {
-               _inotify_event_post(watch->inotify, PEPPER_INOTIFY_EVENT_TYPE_MODIFY,
+               _inotify_event_post(watch, PEPPER_INOTIFY_EVENT_TYPE_MODIFY,
                                        ev->name, (ev->mask & IN_ISDIR) ? PEPPER_TRUE : PEPPER_FALSE);
        }
 }
@@ -111,6 +112,15 @@ pepper_inotify_event_name_get(pepper_inotify_event_t *ev)
        return ev->name;
 }
 
+PEPPER_API char *
+pepper_inotify_event_path_get(pepper_inotify_event_t *ev)
+{
+       PEPPER_CHECK(ev, return PEPPER_INOTIFY_EVENT_TYPE_NONE,
+                       "Invalid inotify event\n");
+
+       return ev->path;
+}
+
 PEPPER_API pepper_bool_t
 pepper_inotify_event_is_directory(pepper_inotify_event_t *ev)
 {
index 36364fb..b66a3f6 100644 (file)
@@ -62,6 +62,9 @@ pepper_inotify_event_type_get(pepper_inotify_event_t *ev);
 PEPPER_API char *
 pepper_inotify_event_name_get(pepper_inotify_event_t *ev);
 
+PEPPER_API char *
+pepper_inotify_event_path_get(pepper_inotify_event_t *ev);
+
 PEPPER_API pepper_bool_t
 pepper_inotify_event_is_directory(pepper_inotify_event_t *ev);