There are a couple examples of using an FSEvent to listen for changes in the file system.
How to listen for file system changes MAC - kFSEventStreamCreateFlagWatchRoot
and
FSEvents weirdness on OS X Leopard
When creating the event with FSEventStreamCreate
they all seem to pass the callback item just fine. No parameters or anything, just &feCallback
. Basically it seems as if they're passing a variable rather than a function, if that makes sense.
But I'm getting a Use of Undeclared identifier
error when I try to do it. What gives?
FSEventStreamRef stream = FSEventStreamCreate(NULL,
&feCallback, // what does '&' mean? Why are no parameters passed?
&cntxt,
pathsToWatch,
kFSEventStreamEventIdSinceNow,
1,
kFSEventStreamCreateFlagWatchRoot );
and then later have the callback function:
static void feCallback(ConstFSEventStreamRef streamRef,
void* pClientCallBackInfo,
size_t numEvents,
void* pEventPaths,
const FSEventStreamEventFlags eventFlags[],
const FSEventStreamEventId eventIds[])
{
NSLog(@"The file changed!");
}
I'd love some sample code to get the open-source helper object here working: https://bitbucket.org/boredzo/fs-notifier/overview
But same thing. It has the method:
- (id) initWithCallback:(FSEventStreamCallback)newCallback path:(NSString *)newPath;
and I can't pass it a newCallback
because of the error described above.