Re: filesystem notifications
Re: filesystem notifications
- Subject: Re: filesystem notifications
- From: Tom Waters <email@hidden>
- Date: Mon, 28 May 2001 19:04:36 -0700
In my case, I have a document which is maintaining a view of the file
system at a given directory. (a la Finder)
so I fire off an NSTimer with an interval of 1 second that calls a
method which calls NSFileManager fileAttributesAtPath: and gets
fileModificationDate from that dictionary then does a compare: with the
cached date I had when I first opened the directory. If the directory
changed, then I refresh my view.
I was concerned about the performance hit, to the point where I even
benchmarked a bsd fstat() version against this, which was quite a bit
faster, but as it turned out the Foundation version was taking less than
a millisecond, so I figured I'd just use it, gaining back 0.1% of the
cpu didn't seem worth it.
On Monday, May 28, 2001, at 06:53 PM, Rob Rix wrote:
The problem with this method is it misses all changes that don't send
NSWorkspace noteFileSystemChanged messages, which seems to be almost
all of them.
e.g. downloads from most tools, anything happening at the BSD layer,
shell access, etc.
Unfortunately, you're exactly right there.
You have to resort to polling the file system itself to keep up to
date.
How do you do this?