private DirectoryStream<Path> directoryStream(Path dir) throws IOException { // create a matcher and return a filter that uses it. return dir.getFileSystem().provider().newDirectoryStream(dir, filter); } }
@Override public DirectoryStream<Path> newDirectoryStream(final Path dir, final DirectoryStream.Filter<? super Path> filter) throws IOException { return delegate.newDirectoryStream(dir, filter); }
public static DirectoryStream newDirectoryStream(Path dir, String glob) throws IOException { FileSystem fs = dir.getFileSystem(); final PathMatcher matcher = fs.getPathMatcher("glob:" + glob); DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() { public boolean accept(Path entry) { return matcher.matches(entry.getFileName()); } }; return fs.provider().newDirectoryStream(dir, filter); }
@Override public DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException { return delegate.newDirectoryStream(resolveRelative(dir), filter); }
/** * Opens a directory stream on provided 'dir' folder, filtering file names according * to the provided glob syntax. * <p> * See http://blog.eyallupu.com/2011/11/java-7-working-with-directories.html * * @param dir the directory to read from * @param glob the glob matching * @return the opened DirectoryStream (remaining to be closed) * @throws IOException if anything goes wrong */ public static DirectoryStream newDirectoryStream (Path dir, String glob) throws IOException { // create a matcher and return a filter that uses it. final FileSystem fs = dir.getFileSystem(); final PathMatcher matcher = fs.getPathMatcher("glob:" + glob); final DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() { @Override public boolean accept (Path entry) { return matcher.matches(entry.getFileName()); } }; return fs.provider().newDirectoryStream(dir, filter); }
@Test public void testNewDirectoryStreamOtherProvider() throws IOException { assertThatThrownBy( () -> FS.provider().newDirectoryStream( otherProviderAbsA(), null ) ).isInstanceOf( ProviderMismatchException.class ); }
@Override public DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException { Path r = unroot(dir); FileSystemProvider p = provider(r); return p.newDirectoryStream(r, filter); }
@Override public DirectoryStream<Path> newDirectoryStream(final Path dir, final Filter<? super Path> filter) throws IOException { return wrapped().newDirectoryStream(unwrap(dir), filter); }
@Override public DirectoryStream<Path> newDirectoryStream(Path dir, final Filter<? super Path> filter) throws IOException { final BundleFileSystem fs = (BundleFileSystem) dir.getFileSystem(); final DirectoryStream<Path> stream = origProvider(dir) .newDirectoryStream(fs.unwrap(dir), new Filter<Path>() { @Override public boolean accept(Path entry) throws IOException { return filter.accept(fs.wrap(entry)); } }); return new DirectoryStream<Path>() { @Override public void close() throws IOException { stream.close(); } @Override public Iterator<Path> iterator() { return fs.wrapIterator(stream.iterator()); } }; }
} else if ("jar".equals(uri.getScheme())) { try (FileSystem fileSystem = FileSystems.newFileSystem(uri, Collections.emptyMap()); DirectoryStream<Path> directoryStream = fileSystem.provider().newDirectoryStream(fileSystem.getPath(type.getDirectoryName()), x -> true)) { Set<String> namespaces = new HashSet<>(); for (Path p : directoryStream) {
final DirectoryStream<Path> dirStream = FS_PROVIDER.newDirectoryStream( Paths.get(path), filter
final DirectoryStream<Path> dirStream = FS_PROVIDER.newDirectoryStream( Paths.get(path), filter
@Override public DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException { Path r = unroot(dir); FileSystemProvider p = provider(r); return root(((RootedPath) dir).getFileSystem(), p.newDirectoryStream(r, filter)); }
@Override public DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException { Path r = unroot(dir); FileSystemProvider p = provider(r); return root(((RootedPath) dir).getFileSystem(), p.newDirectoryStream(r, filter)); }