/** * Fire directory/file change events to the registered listeners. * * @param entry The previous file system entry * @param path The current file */ private void doMatch(final FileStatusEntry entry, final Path path) throws IOException { if (entry.refresh(path)) { for (final PathAlterationListener listener : listeners.values()) { if (entry.isDirectory()) { listener.onDirectoryChange(path); } else { listener.onFileChange(path); } } } }
/** * Create a new FileStatusEntry for the specified file. * * @param parent The parent file entry * @param childPath The file to create an entry for * @return A new file entry */ private FileStatusEntry createPathEntry(final FileStatusEntry parent, final Path childPath) throws IOException { final FileStatusEntry entry = parent.newChildInstance(childPath); entry.refresh(childPath); final FileStatusEntry[] children = doListPathsEntry(childPath, entry); entry.setChildren(children); return entry; }
/** * Initialize the observer. * @throws IOException if an error occurs */ public void initialize() throws IOException { rootEntry.refresh(rootEntry.getPath()); final FileStatusEntry[] children = doListPathsEntry(rootEntry.getPath(), rootEntry); rootEntry.setChildren(children); }
/** * Fire directory/file change events to the registered listeners. * * @param entry The previous file system entry * @param path The current file */ private void doMatch(final FileStatusEntry entry, final Path path) throws IOException { if (entry.refresh(path)) { for (final PathAlterationListener listener : listeners.values()) { if (entry.isDirectory()) { listener.onDirectoryChange(path); } else { listener.onFileChange(path); } } } }
/** * Create a new FileStatusEntry for the specified file. * * @param parent The parent file entry * @param childPath The file to create an entry for * @return A new file entry */ private FileStatusEntry createPathEntry(final FileStatusEntry parent, final Path childPath) throws IOException { final FileStatusEntry entry = parent.newChildInstance(childPath); entry.refresh(childPath); final FileStatusEntry[] children = doListPathsEntry(childPath, entry); entry.setChildren(children); return entry; }
/** * Initialize the observer. * @throws IOException if an error occurs */ public void initialize() throws IOException { rootEntry.refresh(rootEntry.getPath()); final FileStatusEntry[] children = doListPathsEntry(rootEntry.getPath(), rootEntry); rootEntry.setChildren(children); }