/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Unix implementation of java.nio.file.DirectoryStream
*/
class UnixDirectoryStream
implements DirectoryStream<Path>
{
// path to directory when originally opened
// directory pointer (returned by opendir)
private final long dp;
// filter (may be null)
// used to coorindate closing of directory stream
new ReentrantReadWriteLock(true);
// indicates if directory stream is open (synchronize on closeLock)
private volatile boolean isClosed;
// directory iterator
/**
* Initializes a new instance
*/
}
return dir;
}
return streamLock.readLock();
}
return streamLock.writeLock();
}
protected final boolean isOpen() {
return !isClosed;
}
if (!isClosed) {
isClosed = true;
try {
} catch (UnixException x) {
throw new IOException(x.errorString());
}
return true;
} else {
return false;
}
}
public void close()
throws IOException
{
try {
closeImpl();
} finally {
}
}
if (isClosed) {
throw new IllegalStateException("Directory stream is closed");
}
synchronized (this) {
throw new IllegalStateException("Iterator already obtained");
return iterator;
}
}
return iterator(this);
}
/**
* Iterator implementation
*/
// true when at EOF
private boolean atEof;
// next entry to return
atEof = false;
}
// Return true if file name is "." or ".."
return true;
}
}
return false;
}
// Returns next entry (or null)
for (;;) {
byte[] nameAsBytes = null;
// prevent close while reading
try {
if (isOpen()) {
}
} catch (UnixException x) {
throw new DirectoryIteratorException(ioe);
} finally {
}
// EOF
if (nameAsBytes == null) {
atEof = true;
return null;
}
// ignore "." and ".."
if (!isSelfOrParent(nameAsBytes)) {
// return entry if no filter or filter accepts it
try {
return entry;
} catch (IOException ioe) {
throw new DirectoryIteratorException(ioe);
}
}
}
}
public synchronized boolean hasNext() {
nextEntry = readNextEntry();
}
result = readNextEntry();
} else {
}
throw new NoSuchElementException();
return result;
}
public void remove() {
throw new UnsupportedOperationException();
}
}
}