To use eio_monitor_add(), you have to define callbacks for events declared by eio.
Available events are :
- EIO_MONITOR_FILE_CREATED
- EIO_MONITOR_FILE_DELETED
- EIO_MONITOR_FILE_MODIFIED
- EIO_MONITOR_FILE_CLOSED
- EIO_MONITOR_DIRECTORY_CREATED
- EIO_MONITOR_DIRECTORY_DELETED
- EIO_MONITOR_DIRECTORY_CLOSED
- EIO_MONITOR_SELF_RENAME
- EIO_MONITOR_SELF_DELETED
As nothing is worth an example, here it is :
#include <Ecore.h>
#include <Eio.h>
void file_modified(void *data, int type, void *event)
{
const char *filename = (const char *)data;
printf("file %s ", filename);
printf("is being modified");
printf("is no longer being modified");
else printf("got unexpected changes");
printf("\n");
}
int main(int argc, char **argv) {
Eio_Monitor *monitor = NULL,
*monitor2 = NULL;
}
Build the example doing :
gcc -o tutorial_monitor_add tutorial_monitor_add.c `pkg-config --libs --cflags eio ecore ecore-file eina`
* then create the file /tmp/eio_notify_testfile :
* touch /tmp/eio_notify_testfile
* and launch tutorial_monitor_add, and in another terminal, write into /tmp/eio_notify_testfile, doing for example :
* echo "test" >> /tmp/eio_notify_testfile
*