FROM : Uli Kusterer
DATE : Fri Aug 04 20:33:53 2006
Am 04.08.2006 um 17:47 schrieb Paul Schulze:
> Is there a recommended way to listen to changes of files? I'm
> trying to write an application, that provides information about
> various files, that may be distributed over the whole home
> directory of a user. I would like to simply register the file, I'm
> watching and then get an event call on changes. Is there any way to
> do this? Couldn't find anything by now, so any hint would be nice.
If you can require 10.3 or later, kqueue is your friend. If you
want a Cocoa wrapper, I wrote one:
http://www.zathras.de/angelweb/sourcecode.htm#UKKQueue
It also contains an FNSubscribe-based file watching mechanism, which
is the other scheme Apple provides. Both have their advantages and
disadvantages.
Be careful, though. Many apps (especially Cocoa ones) don't change
files, but rather write a new one with the changed contents and then
swap them out once the new one has successfully been written. So, you
may only get one "delete" notification instead of a change.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
DATE : Fri Aug 04 20:33:53 2006
Am 04.08.2006 um 17:47 schrieb Paul Schulze:
> Is there a recommended way to listen to changes of files? I'm
> trying to write an application, that provides information about
> various files, that may be distributed over the whole home
> directory of a user. I would like to simply register the file, I'm
> watching and then get an event call on changes. Is there any way to
> do this? Couldn't find anything by now, so any hint would be nice.
If you can require 10.3 or later, kqueue is your friend. If you
want a Cocoa wrapper, I wrote one:
http://www.zathras.de/angelweb/sourcecode.htm#UKKQueue
It also contains an FNSubscribe-based file watching mechanism, which
is the other scheme Apple provides. Both have their advantages and
disadvantages.
Be careful, though. Many apps (especially Cocoa ones) don't change
files, but rather write a new one with the changed contents and then
swap them out once the new one has successfully been written. So, you
may only get one "delete" notification instead of a change.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
| Related mails | Author | Date |
|---|---|---|
| Paul Schulze | Aug 4, 17:47 | |
| Rosyna | Aug 4, 17:58 | |
| j o a r | Aug 4, 17:59 | |
| Uli Kusterer | Aug 4, 20:33 |






Cocoa mail archive

