diff options
author | Dmitrij D. Czarkoff <czarkoff@gmail.com> | 2015-12-28 11:33:16 +0100 |
---|---|---|
committer | Dmitrij D. Czarkoff <czarkoff@gmail.com> | 2015-12-28 11:49:52 +0100 |
commit | c6096967e3d8d98f24210d4c66e4d22509bdce5c (patch) | |
tree | 6d447519cb6f20a8cf56023ef0ef2d9a17598338 /src/reload.c | |
parent | d0b041f17c34fc36fc8121cfe23e2da2b79cf4fa (diff) | |
download | imv-c6096967e3d8d98f24210d4c66e4d22509bdce5c.tar.gz |
Use stat(2) to monitor file changes
Makes file monitoring in imv completely POSIX.
Diffstat (limited to 'src/reload.c')
-rw-r--r-- | src/reload.c | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/reload.c b/src/reload.c deleted file mode 100644 index a307d45..0000000 --- a/src/reload.c +++ /dev/null @@ -1,49 +0,0 @@ -#include <sys/inotify.h> -#include <stdio.h> -#include <unistd.h> -#include <errno.h> - -#include "reload.h" - -void imv_init_reload(struct imv_reload *rld) -{ - rld->fd = inotify_init1(IN_NONBLOCK); - if(rld->fd == -1) { - perror("imv_init_reload"); - } - - rld->wd = 0; -} - -void imv_reload_watch(struct imv_reload *rld, const char *path) -{ - if(rld->wd != 0) { - inotify_rm_watch(rld->fd, rld->wd); - } - - rld->wd = inotify_add_watch(rld->fd, path, IN_CLOSE_WRITE); - if(rld->wd == -1) { - perror("imv_reload_watch"); - } -} - -int imv_reload_changed(struct imv_reload *rld) -{ - struct inotify_event ev; - ssize_t len = read(rld->fd, &ev, sizeof(ev)); - - if(len < 0) { - if(errno != EAGAIN) { - perror("imv_reload_changed"); - } - } else if(ev.mask & IN_CLOSE_WRITE) { - return 1; - } - - return 0; -} - -void imv_destroy_reload(struct imv_reload *rld) -{ - close(rld->fd); -} |