/** * Returns a snapshot mapping the names of each file in the directory at the given path to the * last modified time of that file. */ public ImmutableMap<Name, Long> snapshotModifiedTimes(JimfsPath path) throws IOException { ImmutableMap.Builder<Name, Long> modifiedTimes = ImmutableMap.builder(); store.readLock().lock(); try { Directory dir = (Directory) lookUp(path, Options.FOLLOW_LINKS) .requireDirectory(path) .file(); // TODO(cgdecker): Investigate whether WatchServices should keep a reference to the actual // directory when SecureDirectoryStream is supported rather than looking up the directory // each time the WatchService polls for (DirectoryEntry entry : dir) { if (!entry.name().equals(Name.SELF) && !entry.name().equals(Name.PARENT)) { modifiedTimes.put(entry.name(), entry.file().getLastModifiedTime()); } } return modifiedTimes.build(); } finally { store.readLock().unlock(); } }
/** * Creates a new directory stream for the directory located by the given path. The given * {@code basePathForStream} is that base path that the returned stream will use. This will be * the same as {@code dir} except for streams created relative to another secure stream. */ public DirectoryStream<Path> newDirectoryStream( JimfsPath dir, DirectoryStream.Filter<? super Path> filter, Set<? super LinkOption> options, JimfsPath basePathForStream) throws IOException { Directory file = (Directory) lookUpWithLock(dir, options) .requireDirectory(dir) .file(); FileSystemView view = new FileSystemView(store, file, basePathForStream); JimfsSecureDirectoryStream stream = new JimfsSecureDirectoryStream(view, filter, state()); return store.supportsFeature(Feature.SECURE_DIRECTORY_STREAM) ? stream : new DowngradedDirectoryStream(stream); }
/** * Returns a snapshot mapping the names of each file in the directory at the given path to the * last modified time of that file. */ public ImmutableMap<Name, Long> snapshotModifiedTimes(JimfsPath path) throws IOException { ImmutableMap.Builder<Name, Long> modifiedTimes = ImmutableMap.builder(); store.readLock().lock(); try { Directory dir = (Directory) lookUp(path, Options.FOLLOW_LINKS) .requireDirectory(path) .file(); // TODO(cgdecker): Investigate whether WatchServices should keep a reference to the actual // directory when SecureDirectoryStream is supported rather than looking up the directory // each time the WatchService polls for (DirectoryEntry entry : dir) { if (!entry.name().equals(Name.SELF) && !entry.name().equals(Name.PARENT)) { modifiedTimes.put(entry.name(), entry.file().getLastModifiedTime()); } } return modifiedTimes.build(); } finally { store.readLock().unlock(); } }
/** * Creates a new directory stream for the directory located by the given path. The given * {@code basePathForStream} is that base path that the returned stream will use. This will be * the same as {@code dir} except for streams created relative to another secure stream. */ public DirectoryStream<Path> newDirectoryStream( JimfsPath dir, DirectoryStream.Filter<? super Path> filter, Set<? super LinkOption> options, JimfsPath basePathForStream) throws IOException { Directory file = (Directory) lookUpWithLock(dir, options) .requireDirectory(dir) .file(); FileSystemView view = new FileSystemView(store, file, basePathForStream); JimfsSecureDirectoryStream stream = new JimfsSecureDirectoryStream(view, filter, state()); return store.supportsFeature(Feature.SECURE_DIRECTORY_STREAM) ? stream : new DowngradedDirectoryStream(stream); }