Re: Filesystem notifications - panther, carbon and kqueue: an odyssey
Re: Filesystem notifications - panther, carbon and kqueue: an odyssey
- Subject: Re: Filesystem notifications - panther, carbon and kqueue: an odyssey
- From: John Clayton <email@hidden>
- Date: Sat, 29 Nov 2003 09:07:13 -0500
Hi Bob,
Subscribing to every file does sound onerous. I am leaning more and
more towards Alistair's suggesstion (and I think Apple's recomended
practice) of updating the tree on certain app events, like becoming
active. I would be working with a small-ish tree (~3k files max I
think). Your situation sounds more challenging-scouring the entire FS
for certain types of changes. Did you see Alistair's link to FAM?
This looks promising:
http://oss.sgi.com/projects/fam/
If I find the the simpler approach is inadequate, I may look deeper
into this one.
On Nov 27, 2003, at 12:44 AM, Bob T. Quone wrote:
If you do find a way to do this nicely, please please please post it
on this list. I'm in the exact same situation (started with Java,
moved to Obj-C) and one of the apps I'm working on would like to know
when files anywhere on the drive change in certain ways to update its
representation of the filesystem. We (meaning my friend, who's better
with carbon and kernel apis) have gotten kqueue kinda-sorta-maybe
working, but it's far less than ideal. Feel free to email me if you
want some info about what we have done. Currently it works, but you
have to "subscribe" to every file on the disk, and it apparently can't
handle huge numbers of files without some tweaking (specifically,
changing the maxvnodes setting, which we'd rather not change without
understanding).
On Nov 26, 2003, at 6:20 AM, email@hidden wrote:
Message: 13
Date: Wed, 26 Nov 2003 09:13:20 -0500
From: John Clayton <email@hidden>
Subject: Filesystem notifications - panther, carbon and kqueue: an
odyssey
To: Cocoa-Dev Mail <email@hidden>
Ok,
An upfront disclaimer: I am a programmer who arrived at Objective-C
via
Java and who has found myself backing up like a skittish horse into C
and the Unix underpinnings of OS X, which I love. I have the distinct
notion that I am traveling backwards in time on some quest to uncover
the Source-which I guess is sort of true. On the other hand, there's
been this nagging doubt creeping around the edges of my consciousness
for some time and which until now I have successfully REPRESSEDyou
can't really write a complete (and moderately complicated) application
in Cocoa using just Objective-C, you'll have to really learn C,
Carbon,
etc.the voice says. You get the idea; my knowledge of the following
topic and historical solutions is pretty limited.
That being said, I started a week or so ago to scour the lists for
some
tried-and-true to solutions to a challenge that I figured must be a
common one: to find out when the filesystem has changed in such a way
as to be interesting to my outline view. Ok, I see the system save
panel notices changes, so it must be possible. Approaches one finds
discussed on the list:
1) Poll the filesystem. As many say don't so this as bring it up.
Ok,
next.
2) NSWorkspace has fileSytemHasChanged, which I call when my app
becomes active and which never seems to return anything but NO
regardless of what happens on the FS while my app is inactive. I don't
know why.
3) Carbon is the answer! FNSubscribe-it, baby. Ok, aside from the
fact
that just looking over the API documentation for Carbon makes me feel
dizzy I'm willing to do this; I am after all starting to see the light
in C. I'm not scared. Ok, wait, what's an FSRef? Ahhhhh! Is this
going to take me a year to learn? I did find some very useful
examples
here, but none of them complete enough to use out of the box; what did
I expect? But a serious question here: can someone suggest a learning
approach/tools to Carbon that is mostly structural and quick? I.e.
Where can I learn the basics quickly and get a lay of the land so I
might know where to look for answers? (The several books out there
have received mixed reviews).
4) Kqueue to-the-rescue. With panther there is an implementation of
kqueue at the BSD level. Fantastic! What's kqueue? Well a few links
on the list:
* http://homepage.mac.com/calumr/main.m
* http://people.freebsd.org/~jlemon/papers/kqueue.pdf
provide some insight. But I have so little knowledge of what is going
on here, I can't really evaluate whether this is my approach or not.
Seems promising. I am definitely looking deeper into this.
Summation: it would be great to see Cocoa support for some advanced
filesystem change detection techniques. Until then, can anyone shed
some light on the available options and recommend a best-practices
approach? I'd be eternally grateful. Well, grateful for a good long
while anyway.
Cheers,
John
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.