Ramaprasad Upadhyaya
Ramaprasad Upadhyaya

Reputation: 467

FOlder Watcher - Cocoa/Obj C

I need to watch a specified folder for specific type of file (pdf) and get notification only when file is "Created" or "Renamed". I tried many Obj c wrappers like SCEvents, UKKQueue etc., I could not get the type of the event raised("Created" or "Renamed") inside the notification delegate.I am just getting a flag/some#.I also tried FSEventStream which was not raising callback.Refered URL for this:OSX FSEventStreamEventFlags not working correctly.

In SCEvents, I have below delegate which is not telling me the type of event-

- (void)pathWatcher:(SCEvents *)pathWatcher eventOccurred:(SCEvent *)event {

    NSLog(@"%@", event);
}

Getting below log-

2014-02-27 16:41:59.342 PMLauncher6[5187:303] <SCEvent { eventId = 661674, eventPath = /Users/Test, eventFlag = 67584 } >

Any one has any idea on the same or better way to meet the requirement, kindly advise.

Thanks


Upvotes: 0

Views: 222

Answers (1)

macrene
macrene

Reputation: 314

Try NSWorkspace - noteFileSystemChanged:.

The documentation doesn't tell much about it, but as a Notification that "Informs the NSWorkspace object that the file system changed at the specified path." it should fit to your needs.

Upvotes: 2

Related Questions