< prev index next >

src/java.base/share/classes/jdk/internal/jrtfs/JrtDirectoryStream.java

Print this page

        

*** 37,74 **** * DirectoryStream implementation for jrt file system implementations. */ final class JrtDirectoryStream implements DirectoryStream<Path> { private final AbstractJrtFileSystem jrtfs; ! private final byte[] path; ! // prefix to be used for children of this directory ! // so that child path are reported relatively (if needed) ! private final String childPrefix; private final DirectoryStream.Filter<? super Path> filter; private volatile boolean isClosed; private volatile Iterator<Path> itr; JrtDirectoryStream(AbstractJrtPath jrtPath, DirectoryStream.Filter<? super java.nio.file.Path> filter) throws IOException { this.jrtfs = jrtPath.getFileSystem(); ! this.path = jrtPath.getResolvedPath(); // sanity check ! if (!jrtfs.isDirectory(path, true)) { throw new NotDirectoryException(jrtPath.toString()); } - // absolute path and does not have funky chars in front like /./java.base - if (jrtPath.isAbsolute() && (path.length == jrtPath.getPathLength())) { - childPrefix = null; - } else { - // cases where directory content needs to modified with prefix - // like ./java.base, /./java.base, java.base and so on. - String dirName = jrtPath.toString(); - int idx = dirName.indexOf(JrtFileSystem.getString(path).substring(1)); - childPrefix = dirName.substring(0, idx); - } this.filter = filter; } @Override public synchronized Iterator<Path> iterator() { --- 37,61 ---- * DirectoryStream implementation for jrt file system implementations. */ final class JrtDirectoryStream implements DirectoryStream<Path> { private final AbstractJrtFileSystem jrtfs; ! private final AbstractJrtPath dir; private final DirectoryStream.Filter<? super Path> filter; private volatile boolean isClosed; private volatile Iterator<Path> itr; JrtDirectoryStream(AbstractJrtPath jrtPath, DirectoryStream.Filter<? super java.nio.file.Path> filter) throws IOException { this.jrtfs = jrtPath.getFileSystem(); ! this.dir = jrtPath; // sanity check ! if (!jrtfs.isDirectory(dir, true)) { throw new NotDirectoryException(jrtPath.toString()); } this.filter = filter; } @Override public synchronized Iterator<Path> iterator() {
*** 78,88 **** if (itr != null) { throw new IllegalStateException("Iterator has already been returned"); } try { ! itr = jrtfs.iteratorOf(path, childPrefix); } catch (IOException e) { throw new IllegalStateException(e); } return new Iterator<Path>() { /* --- 65,75 ---- if (itr != null) { throw new IllegalStateException("Iterator has already been returned"); } try { ! itr = jrtfs.iteratorOf(dir); } catch (IOException e) { throw new IllegalStateException(e); } return new Iterator<Path>() { /*
< prev index next >