Using Spotlight to watch for file change
Using Spotlight to watch for file change
- Subject: Using Spotlight to watch for file change
- From: Tim Gogolin <email@hidden>
- Date: Wed, 14 Sep 2005 16:16:18 -0500
I'd like to watch one or more specific files to see if an external
program has modified them.
Three methods immediately pop to my mind:
kqueue (which I know almost nothing about),
Spotlight (which seems like it ought to be the right answer)
polling the file mod date (which I'd like to avoid)
There doesn't appear to be a simple way to register for
NSNotifications when a file is changed, so the best I can see is to
make a live Query of the form: kMDItemPath == myFileNameOfInterest
and file's mod date > now. Is this the right approach?
Also, does anyone have any experience with the scalability of
multiple queries? For example, if I have 20 files I want to watch,
would I be better off keeping 20 queries live or one really
complicated query? 100 files? Truly obscene numbers of files
(thousands) are not likely to occur for my expected usage, so perhaps
it doesn't matter overly much...
Have any readers of the list used this type of Spotlight query for
this type of thing? Has a user's privacy settings (don't index this
area) been a problem? I don't think there's a way to detect if the
file path I specify is fated to never trigger a notification because
of privacy settings (so I could fall back to another solution)...
Bummer.
Before I spend a day or two writing sample code to try the
approaches, I was hoping someone might offer opinions based on
similar experiences... Thanks!
-- Tim Gogolin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden