private final Map fileMap = new HashMap();
private final Map handleMap = new HashMap();
private void handleChanges(FileInfo finfo) throws IOException {
Kernel32 klib = Kernel32.INSTANCE;
FILE_NOTIFY_INFORMATION fni = finfo.info;
// Need an explicit read, since data was filled in asynchronously
fni.read();
do {
FileEvent event = null;
File file = new File(finfo.file, fni.getFilename());
switch(fni.Action) {
case Kernel32.FILE_ACTION_MODIFIED:
event = new FileEvent(file, FILE_MODIFIED); break;
case Kernel32.FILE_ACTION_ADDED:
event = new FileEvent(file, FILE_CREATED); break;
case Kernel32.FILE_ACTION_REMOVED:
event = new FileEvent(file, FILE_DELETED); break;
case Kernel32.FILE_ACTION_RENAMED_OLD_NAME:
event = new FileEvent(file, FILE_NAME_CHANGED_OLD); break;
case Kernel32.FILE_ACTION_RENAMED_NEW_NAME:
event = new FileEvent(file, FILE_NAME_CHANGED_NEW); break;
default:
// TODO: other actions...
System.err.println("Unrecognized file action '" + fni.Action + "'");
}
if (event != null)
notify(event);
fni = fni.next();
} while (fni != null);
// Trigger the next read
if (!finfo.file.exists()) {
unwatch(finfo.file);
return;