I want to monitor directories on mac using FSEvent.
This Error is getting generated in root context. If i run program in user context it work properly.
Error is: FSEventStreamCreate: _FSEventStreamCreate: ERROR: watch_path() failed for some_path.
I want to watch array of paths. but creating stream get failed.
its working fine for lower number of paths in root.
code I use to create stream is.
FSEventStreamContext * streamContext = (FSEventStreamContext *)malloc(sizeof(FSEventStreamContext));
streamContext->version = 0;
streamContext->info = NULL;//&fileDescriptor;
streamContext->retain = NULL;
streamContext->release = NULL;
streamContext->copyDescription = NULL;
/* Create the stream, passing in a callback */
stream = FSEventStreamCreate(
NULL,
&myCallbackFunction,
streamContext,
pathsToWatch, /* This is the array of paths I am passing to watch, It work fine in user context for large number of objects too. */
kFSEventStreamEventIdSinceNow, /* Or a previous event ID */
latency,
kFSEventStreamCreateFlagNone | kFSEventStreamCreateFlagWatchRoot /* Flags explained in reference */
);
if (NULL == stream) /* Stream get NULL */
{
NSLog(@"Ruturning False : stream == NULL");
NSLog(@"FSEventStreamCreate failed");
return;
}
Thanks in advance.
kFSEventStreamCreateFlagWatchRoot
flag in functionFSEventStreamCreate()
cause problem, I don't know why.But when I remove that flag it run in root context and user context also for many number of paths.