/*
* 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.
*/
/**
* Windows implementation of DirectoryStream
*/
class WindowsDirectoryStream
implements DirectoryStream<Path>
{
// handle to directory
private final long handle;
// first entry in the directory
// buffer for WIN32_FIND_DATA structure that receives information about file
// need closeLock to access these
private boolean isOpen = true;
throws IOException
{
try {
// Need to append * or \* to match entries in directory.
search += "*";
} else {
search += "\\*";
}
} catch (WindowsException x) {
if (x.lastError() == ERROR_DIRECTORY) {
}
// keep compiler happy
throw new AssertionError();
}
}
public void close()
throws IOException
{
synchronized (closeLock) {
if (!isOpen)
return;
isOpen = false;
}
try {
} catch (WindowsException x) {
}
}
if (!isOpen) {
throw new IllegalStateException("Directory stream is closed");
}
synchronized (this) {
throw new IllegalStateException("Iterator already obtained");
return iterator;
}
}
private boolean atEof;
atEof = false;
if (dir.needsSlashWhenResolving()) {
} else {
}
}
// links to self and parent directories are ignored
}
// applies filter and also ignores "." and ".."
try {
return entry;
} catch (IOException ioe) {
throw new DirectoryIteratorException(ioe);
}
return null;
}
// reads next directory entry
// handle first element returned by search
return nextEntry;
}
for (;;) {
// synchronize on closeLock to prevent close while reading
synchronized (closeLock) {
try {
if (isOpen) {
}
} catch (WindowsException x) {
throw new DirectoryIteratorException(ioe);
}
// NO_MORE_FILES or stream closed
atEof = true;
return null;
}
// ignore link to self and parent directories
if (isSelfOrParent(name))
continue;
// grab the attributes from the WIN32_FIND_DATA structure
// (needs to be done while holding closeLock because close
// will release the buffer)
}
// return entry if accepted by filter
return entry;
}
}
public synchronized boolean hasNext() {
nextEntry = readNextEntry();
}
result = readNextEntry();
} else {
}
throw new NoSuchElementException();
return result;
}
public void remove() {
throw new UnsupportedOperationException();
}
}
}