src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipDirectoryStream.java
Print this page
*** 39,74 ****
*/
class ZipDirectoryStream implements DirectoryStream<Path> {
private final ZipFileSystem zipfs;
! private final byte[] path;
private final DirectoryStream.Filter<? super Path> filter;
private volatile boolean isClosed;
private volatile Iterator<Path> itr;
! ZipDirectoryStream(ZipPath zipPath,
DirectoryStream.Filter<? super java.nio.file.Path> filter)
throws IOException
{
! this.zipfs = zipPath.getFileSystem();
! this.path = zipPath.getResolvedPath();
this.filter = filter;
// sanity check
! if (!zipfs.isDirectory(path))
! throw new NotDirectoryException(zipPath.toString());
}
@Override
public synchronized Iterator<Path> iterator() {
if (isClosed)
throw new ClosedDirectoryStreamException();
if (itr != null)
throw new IllegalStateException("Iterator has already been returned");
try {
! itr = zipfs.iteratorOf(path, filter);
} catch (IOException e) {
throw new IllegalStateException(e);
}
return new Iterator<Path>() {
private Path next;
--- 39,74 ----
*/
class ZipDirectoryStream implements DirectoryStream<Path> {
private final ZipFileSystem zipfs;
! private final ZipPath dir;
private final DirectoryStream.Filter<? super Path> filter;
private volatile boolean isClosed;
private volatile Iterator<Path> itr;
! ZipDirectoryStream(ZipPath dir,
DirectoryStream.Filter<? super java.nio.file.Path> filter)
throws IOException
{
! this.zipfs = dir.getFileSystem();
! this.dir = dir;
this.filter = filter;
// sanity check
! if (!zipfs.isDirectory(dir.getResolvedPath()))
! throw new NotDirectoryException(dir.toString());
}
@Override
public synchronized Iterator<Path> iterator() {
if (isClosed)
throw new ClosedDirectoryStreamException();
if (itr != null)
throw new IllegalStateException("Iterator has already been returned");
try {
! itr = zipfs.iteratorOf(dir, filter);
} catch (IOException e) {
throw new IllegalStateException(e);
}
return new Iterator<Path>() {
private Path next;
*** 96,102 ****
@Override
public synchronized void close() throws IOException {
isClosed = true;
}
-
}
--- 96,101 ----