Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to use FSEvents to get notifications that a folder has been moved?
    primarykey
    data
    text
    <p>I'm using the FSEvents API to get notifications of changes in a local directory that I'm tracking.</p> <p>Is it possible to get a notification that the watched directory has been moved to another location on disk, using FSEvents or anything else?</p> <p>Update:</p> <p>Here is the code I have so far, I'm now trying to use the kFSEventStreamCreateFlagWatchRoot flag with FSEventStreamCreate to get the root changed notification, so far without success.</p> <pre><code>- (void)registerForFileSystemNotifications { NSString *watchedDirectoryPath = [[NSUserDefaults standardUserDefaults] valueForKey:kMyWatchedDirectoryPathKey]; self.watchedDirectoryFileDescriptor = open([watchedDirectoryPath cStringUsingEncoding:NSUTF8StringEncoding], O_RDONLY); NSArray *paths = [NSArray arrayWithObject:watchedDirectoryPath]; void *appController = (void *)self; FSEventStreamContext context = {0, appController, NULL, NULL, NULL}; FSEventStreamRef streamRef = FSEventStreamCreate(NULL, &amp;fsevents_callback, &amp;context, (CFArrayRef) paths, kFSEventStreamEventIdSinceNow, (CFTimeInterval)2.0, kFSEventStreamCreateFlagUseCFTypes | kFSEventStreamCreateFlagWatchRoot); FSEventStreamScheduleWithRunLoop(streamRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); FSEventStreamStart(streamRef); } void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t numumberOfEvents, void *eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[]) { MyAppController *appController = (MyAppController *)userData; char *newPath = calloc(4096, sizeof(char)); int pathIntPointer = (int)newPath; int length = fcntl(appController.watchedDirectoryFileDescriptor, F_GETPATH, pathIntPointer); NSString *newPathString = [[NSString alloc] initWithBytes:newPath length:(NSUInteger)length encoding:NSUTF8StringEncoding]; NSLog(@"newPathString: %@", newPathString); // empty } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload