Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > FileSystemWatcher class equivalent in OS X?

FileSystemWatcher class equivalent in OS X?
Thread Tools
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Nov 26, 2006, 06:22 PM
 
I'm trying to figure out how to detect when a file changes (i.e. is modified, created, etc) in OS X, similar to the .NET way with FileSystemWatcher class (see http://msdn2.microsoft.com/en-us/lib...emwatcher.aspx ) Any ideas?

Thanks!
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Nov 26, 2006, 06:40 PM
 
The Mac API for watching files is the kqueue function. Uli Kusterer has created a Cocoa wrapper for it. (There's also an unrelated Carbon API for watching files, but I don't think it's as precise.)
(Last edited by Chuckit; Nov 26, 2006 at 06:46 PM. )
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Mac Elite
Join Date: Aug 2001
Status: Offline
Reply With Quote
Nov 26, 2006, 11:37 PM
 
Originally Posted by Chuckit View Post
(There's also an unrelated Carbon API for watching files, but I don't think it's as precise.)
It's really pretty useless in my experience; I spent a while back on 10.3 trying to write a spotlight-alike (locate + dynamically updating db, basically). Ended up giving up on it due to the lack of good file monitoring APIs in 10.3.
     
timmerk  (op)
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Nov 27, 2006, 07:54 AM
 
Originally Posted by Catfish_Man View Post
It's really pretty useless in my experience; I spent a while back on 10.3 trying to write a spotlight-alike (locate + dynamically updating db, basically). Ended up giving up on it due to the lack of good file monitoring APIs in 10.3.
What is useless? The Carbon way, or the kqueue way, or both?

Thanks!
     
Mac Elite
Join Date: Aug 2001
Status: Offline
Reply With Quote
Nov 27, 2006, 07:58 AM
 
The Carbon API for file watching. kqueue works great for a limited number of files (and Uli's objc wrapper for it is great ), although it still doesn't meet the needs of something like spotlight that has to watch the entire filesystem.
     
Mac Elite
Join Date: Jul 2002
Status: Offline
Reply With Quote
Nov 27, 2006, 08:12 PM
 
There will be Leopard API enhancements in this area.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:41 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2