Re: Capturing file system events
Re: Capturing file system events
- Subject: Re: Capturing file system events
- From: Jim Magee <email@hidden>
- Date: Thu, 13 Nov 2003 14:18:21 -0500
On Nov 13, 2003, at 9:56 AM, Ken Tozier wrote:
A project I'm working on needs to be able to capture the following
three file system events in order to write those changes to a log
file:
- Container changed events (when file is moved from one directory to
another on the same volume)
- Name changed events
- File add events (when files are added to watch folders or any of the
watch folder's sub folders from a different volume)
AppleScript's folder actions are in the ball park conceptually, but
their inability to operate on closed folders and the fact that if
something in a deeply nested folder hierarchy changes, those changes
don't propagate to higher level directories, make folder actions
unsuitable for my needs.
Would a Kext be the place to capture these types of file events in
real time?
There is no need for a kext.
Depending upon the filesystem type in question (I'll assume local HFS+
or UFS), you can use kqueue(2) and kevent(2) syscalls to watch
folder/directory changes like these. Now, nothing in those APIs does
the automatic recursion to sub-folders/directories, but you can do that
yourself. The directory files must be held open (so limits on
filedescriptors per process may have to be raised). There is also a
new open(2) flag (O_EVTONLY) that won't hold up volume unmounts while
watching for changes.
If you are writing a Carbon application, and only need to see changes
done at the Finder/application level (not backdoor changes by
command-line applications) you can use higher level notifications like
FNNotify().
--Jim
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.