Re: Identifying directory changes with kqueue/kevent
Re: Identifying directory changes with kqueue/kevent
- Subject: Re: Identifying directory changes with kqueue/kevent
- From: Uli Kusterer <email@hidden>
- Date: Sun, 7 Oct 2007 12:36:36 +0200
Am 19.09.2007 um 17:43 schrieb Fred Leboucher:
I'm trying to watch a directory for changes, so the couple kqueue/
kevent could do the job (aside from the Carbon FNSubscribe). Only
problem is that, like FNSubscribe, kqueue/kevent can't tell what
file in the directory changed (or maybe I missed something ?).
So, is there any simple way to identify the changed file, or do I
have to keep track of all files in the directory, and compare this
to the directory every time a change occurs ? This could be quite
expensive and handling events like file renaming would be a real
pain...
I don't think you necessarily have to keep track of much. One of
the dates (last accessed, last changed, created etc.) will likely
have changed by the time you get your kevent (that's a guess, back
when I did stuff like that, I didn't really think of that approach,
so you will have to verify that part).
If my guess is right, you could probably just note down the newest
date at the time of your last check, and any file with a newer date
must have changed in the meantime. Also, FSGetCatalogInfoBulk() or
maybe FSCatSearch() or whatever it was called should be fast enough
to get that information for a folder when it changes. I've found
that, since you've already narrowed down the files to be examined
using kqueue, scanning a single folder should work pretty well.
In addition, you could use a timer to coalesce several messages on
the same folder that arrive in a short succession, to avoid having to
re-scan the same folder several times.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden