0

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


Community
  • 1
  • 1

1 Answers1

2

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.

Monolo
  • 18,205
  • 17
  • 69
  • 103
macrene
  • 198
  • 1
  • 8
  • Looked at NSWorkSpace documentation. Looks like all of these methods seems to be depricated... Deprecated in OS X v10.6. Use the FSEvents API described in FSEvents Reference instead.) https://developer.apple.com/librarY/mac/documentation/Darwin/Reference/FSEvents_Ref/Reference/reference.html#//apple_ref/doc/uid/TP40004723 Any other advise? – Ramaprasad Upadhyaya Feb 27 '14 at 14:53
  • You're right, some are, but "noteFileSystemChanged:" is still alive. Watch the ":" please. Haven't worked with FSEvents. – macrene Feb 27 '14 at 16:12
  • Thanks. Do you have any usage example for the same? How to get the callback/delegate when folder is changed. – Ramaprasad Upadhyaya Feb 28 '14 at 04:51