Is there a good objc library wrapper for / kqueue file system events that handles recursive observations of me?

I want to write an OSX (Snow Leopard) application that receives notifications when files in a specific directory are changed, and I want to access the path to a specific file that has been changed.

I know I can do this using File System Eventsor kqueue. The first one does not contain information about which specific file was modified (it required me to create a snapshot of the directory that I am viewing and then scan to find out which file was modified). The latter does not support recursive browsing (requiring me to add a clock recursively to each file and directory in the parent directory).

I was looking for libraries that handle snapshots / recursions for me, but cannot find them. UKKQueueLooks like a good wrapper for low-level stuff kqueue, but doesn't seem to recurs. The same for GTMFileSystemKQueue. SCEventsLooks like a good wrapper for File System Events, but doesn't seem to cope with finding a specific modified file.

Is there a library that does what I want and is suitable for the objc project for any of these technologies?

+5
source share
1 answer

I ended up using it GTMFileSystemKQueueafter I found out how easy it is to recursively loop through a directory in objc:

// Create a directory enumerator for the given top level directory
NSDirectoryEnumerator *de = [[NSFileManager defaultManager] enumeratorAtPath:dir];

// Add a kqueue on every file and folder below the top level
NSString *file;
while ((file = [de nextObject])) {
    [[GTMFileSystemKQueue alloc] initWithPath:[dir stringByAppendingString:file]
                                    forEvents:kGTMFileSystemKQueueAllEvents
                                acrossReplace:YES
                                       target:self
                                       action:@selector(fileSystemKQueue:events:)];
}
0
source