Adam Fisk <email@hidden> wrote:
>Does anyone know of an open source, cross platform library for receiving
>file system events in Java? I noticed your POSIX library, Greg. Does
>it generate an event when, for example, a file is added to a directory
>or when a file in a watched directory is changed?
Posix doesn't have any "file system events", as far as I know. It
certainly doesn't use signals for that purpose, and I know of no other
events or event-like objects it could be.
The closest you might come on Mac OS X is the FileForker.Watcher API in
MacBinary Toolkit:
<http://www.amug.org/~glguerin/sw/#macbinary>
However, the Watcher only works in limited cases, and may not work at all
in some cases (I haven't tested it for a while) Besides, a Watcher only
responds to an actual sending of a change-event under the Mac OS X API for
file-system events. A Watcher does not respond when the thing itself
changes. That is, an application must send the change-event overtly.
There isn't a system-wide daemon keeping track of the file-system and
independently creating and sending change-events.
The best Java solution is probably Glen's suggestion:
write a thread that periodically monitors what you want.
Be aware that no Java API provides any guarantees about when metadata is
flushed to disk, though, (it's OS dependent). So even an apparently
portable Java solution might not work in some situations.
The filesystem is underspecified in Java, and is one of the big areas
that's most platform-specific. For example, even buffers and file-locking
have a lot of disclaimers about platform-dependent behavior, yet they have
perhaps the best-written specs in the Java class libraries.
Any Java class referring to the file-system may be platform-dependent or
implementation-dependent even though it doesn't have flashing red lights
and sirens warning you it's platform-dependent. It could even by
disk-format dependent, such as case-sensitivity of pathnames, which is true
for UFS-formatted disks, but untrue of HFS, HFS+, and DOS formats, all on
the same platform (Mac OS X) running one Java program.
-- GG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden