Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

In an FSEvents callback, how can I determine which directory being watched caused an event to be triggered?

Hi there,


In C++ code, I have an array of directories being watched using the file systems events API. It works at the individual file level, that is, the FSEventStreamRef is created using the flag


kFSEventStreamCreateFlagFileEvents


Now, in the callback, I would like to specify custom callback functions for each directory being watched. But this requires knowing the specific directory being watched that triggered the event. Accessing this informaiton doesn't seem possible. The closest function I have seen is


FSEventStreamCopyPathsBeingWatched


which will return an array of paths being watched. But this isn't enough to determine the precise directory that triggered the event.


I hope what I am trying to do makes sense.


Many thanks,

Ben.



Mac OS X (10.7.4)

Posted on Oct 11, 2012 2:36 AM

Reply
Question marked as Best reply

Posted on Oct 11, 2012 2:22 PM

How can you have a handler for each directory being watched when you are watching files? You would have to check each path for the prefix of one of the directories you are interested in.

1 reply

In an FSEvents callback, how can I determine which directory being watched caused an event to be triggered?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.