208 { |
208 { |
209 UnixPath dir = (UnixPath)obj; |
209 UnixPath dir = (UnixPath)obj; |
210 |
210 |
211 int mask = 0; |
211 int mask = 0; |
212 for (WatchEvent.Kind<?> event: events) { |
212 for (WatchEvent.Kind<?> event: events) { |
213 if (event == StandardWatchEventKind.ENTRY_CREATE) { |
213 if (event == StandardWatchEventKinds.ENTRY_CREATE) { |
214 mask |= IN_CREATE | IN_MOVED_TO; |
214 mask |= IN_CREATE | IN_MOVED_TO; |
215 continue; |
215 continue; |
216 } |
216 } |
217 if (event == StandardWatchEventKind.ENTRY_DELETE) { |
217 if (event == StandardWatchEventKinds.ENTRY_DELETE) { |
218 mask |= IN_DELETE | IN_MOVED_FROM; |
218 mask |= IN_DELETE | IN_MOVED_FROM; |
219 continue; |
219 continue; |
220 } |
220 } |
221 if (event == StandardWatchEventKind.ENTRY_MODIFY) { |
221 if (event == StandardWatchEventKinds.ENTRY_MODIFY) { |
222 mask |= IN_MODIFY | IN_ATTRIB; |
222 mask |= IN_MODIFY | IN_ATTRIB; |
223 continue; |
223 continue; |
224 } |
224 } |
225 } |
225 } |
226 |
226 |
376 /** |
376 /** |
377 * map inotify event to WatchEvent.Kind |
377 * map inotify event to WatchEvent.Kind |
378 */ |
378 */ |
379 private WatchEvent.Kind<?> maskToEventKind(int mask) { |
379 private WatchEvent.Kind<?> maskToEventKind(int mask) { |
380 if ((mask & IN_MODIFY) > 0) |
380 if ((mask & IN_MODIFY) > 0) |
381 return StandardWatchEventKind.ENTRY_MODIFY; |
381 return StandardWatchEventKinds.ENTRY_MODIFY; |
382 if ((mask & IN_ATTRIB) > 0) |
382 if ((mask & IN_ATTRIB) > 0) |
383 return StandardWatchEventKind.ENTRY_MODIFY; |
383 return StandardWatchEventKinds.ENTRY_MODIFY; |
384 if ((mask & IN_CREATE) > 0) |
384 if ((mask & IN_CREATE) > 0) |
385 return StandardWatchEventKind.ENTRY_CREATE; |
385 return StandardWatchEventKinds.ENTRY_CREATE; |
386 if ((mask & IN_MOVED_TO) > 0) |
386 if ((mask & IN_MOVED_TO) > 0) |
387 return StandardWatchEventKind.ENTRY_CREATE; |
387 return StandardWatchEventKinds.ENTRY_CREATE; |
388 if ((mask & IN_DELETE) > 0) |
388 if ((mask & IN_DELETE) > 0) |
389 return StandardWatchEventKind.ENTRY_DELETE; |
389 return StandardWatchEventKinds.ENTRY_DELETE; |
390 if ((mask & IN_MOVED_FROM) > 0) |
390 if ((mask & IN_MOVED_FROM) > 0) |
391 return StandardWatchEventKind.ENTRY_DELETE; |
391 return StandardWatchEventKinds.ENTRY_DELETE; |
392 return null; |
392 return null; |
393 } |
393 } |
394 |
394 |
395 /** |
395 /** |
396 * Process event from inotify |
396 * Process event from inotify |
398 private void processEvent(int wd, int mask, final UnixPath name) { |
398 private void processEvent(int wd, int mask, final UnixPath name) { |
399 // overflow - signal all keys |
399 // overflow - signal all keys |
400 if ((mask & IN_Q_OVERFLOW) > 0) { |
400 if ((mask & IN_Q_OVERFLOW) > 0) { |
401 for (Map.Entry<Integer,LinuxWatchKey> entry: wdToKey.entrySet()) { |
401 for (Map.Entry<Integer,LinuxWatchKey> entry: wdToKey.entrySet()) { |
402 entry.getValue() |
402 entry.getValue() |
403 .signalEvent(StandardWatchEventKind.OVERFLOW, null); |
403 .signalEvent(StandardWatchEventKinds.OVERFLOW, null); |
404 } |
404 } |
405 return; |
405 return; |
406 } |
406 } |
407 |
407 |
408 // lookup wd to get key |
408 // lookup wd to get key |