PDA

View Full Version : File Change




sivaprakash
Jun 16, 2011, 05:10 AM
Hi

What are the options available in COCOA to handle file/directory changes actively. For example if there is a change in any given directory then there should be an alert sent to another program which is running.

Thanks
Siva



jiminaus
Jun 16, 2011, 05:35 AM
It's not at the Cocoa level, but checked out the File System Event API.

File System Events Programming Guide (http://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/FSEvents_ProgGuide)

Monitoring File Changes with the File System Events API (http://developer.apple.com/library/mac/#featuredarticles/FileSystemEvents)

EDIT: Google also found UKKQueue at http://zathras.de/angelweb/sourcecode.htm. It is a Cocoa API build around the low-level kqueue/kevent API. But it's last update seems to have been in 2006, putting in tiger territory.

gnasher729
Jun 16, 2011, 06:42 AM
It's not at the Cocoa level, but checked out the File System Event API.

File System Events Programming Guide (http://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/FSEvents_ProgGuide)

Monitoring File Changes with the File System Events API (http://developer.apple.com/library/mac/#featuredarticles/FileSystemEvents)

EDIT: Google also found UKKQueue at http://zathras.de/angelweb/sourcecode.htm. It is a Cocoa API build around the low-level kqueue/kevent API. But it's last update seems to have been in 2006, putting in tiger territory.

In my experience, FSEventStream is the easiest to use and most reliable.