I recently switched from using kqueue to GCD dispatch sources to monitor file changes. This has worked out well and resulted in a much simpler API. I documented my switch here. The only issue I have is that now I cannot access the flags on the event that I was able to in kqueue. For example with kqueue I was able to check if the file was deleted, renamed, or it’s attributes were changed with the following:
struct kevent event;
...
if(event.flag & EV_DELETE)
{
printf("File was deleted\n");
}
Is this API not available with GCD or do I need to set up dispatch sources up for each flag I would like to listen to. Or is it best to use kqueue since it provides greater visibility to the event that has occurred.
I found the answer in the Concurrency Programming Guide. I had first looked in the GCD Reference but without luck. The relevant line from the guide was
Here is an example of how you can use it.