Re: Identifying directory changes with kqueue/kevent
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Cheers, -- M. Uli Kusterer http://www.zathras.de _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... 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. This email sent to site_archiver@lists.apple.com
participants (1)
-
Uli Kusterer