4 messages in net.java.dev.jna.usersRe: [jna-users] multiple directories ...
FromSent OnAttachments
Stephen ZackNov 2, 2007 8:29 am 
Timothy WallNov 2, 2007 11:44 am 
Doug PatriarcheNov 5, 2007 7:34 am 
Timothy WallNov 6, 2007 8:37 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] multiple directories with FileMonitorActions...
From:Timothy Wall (twal@dev.java.net)
Date:Nov 2, 2007 11:44:58 am
List:net.java.dev.jna.users

On Nov 2, 2007, at 11:29 AM, Stephen Zack wrote:

Using the latest examples.jar, to set up a process to monitor multiple file directories with FileMonitor (I spawned separate FileMonitor instances), I encountered a problem that the class only returns file events from the last monitored directory.

From eclipse, I noticed that the Kernel32 interface contains a static FILE_NOTIFY_INFORMATION structure subclass. Could that be reason I’m only seeing changes in one directory? (Should this logically be a static element?)

Acknowledging that this is only an example class, is there an easier way to fix this, short of writing an entirely new Kernel32 interface?

Thanks in advance for any assistance.

The "static"-ness of the class merely means that it does not have a reference to an instance of the enclosing class; in this case it allows the structure to be used independently of the interface, and yet stay associated with that interface.

Yes it's only an example, but I think it's reasonable to expect it to work for more than one directory entry. Chances are I made some mistake in translating from the original W32 API example. One guess would be that you might need to use a single IO completion port for *all* dir entries, rather than setting up a new one for each (glancing at the code now, I see there's a single "port" member, that gets overwritten with each added file).

I'm happy to roll in fixes for this if you solve it; you should start with a corresponding JUnit test that watches *two* files (the existing test only looks at one...). I'm happy to take a look at it further, but may not have time for a little while.

T.