--- old/src/windows/classes/sun/nio/fs/WindowsDirectoryStream.java Sat Oct 22 15:11:35 2011 +++ new/src/windows/classes/sun/nio/fs/WindowsDirectoryStream.java Sat Oct 22 15:11:34 2011 @@ -124,6 +124,9 @@ private boolean atEof; private String first; private Path nextEntry; + private StringBuilder prefix; + private WindowsFileSystem fileSystem; + private int prefixLength; WindowsDirectoryIterator(String first) { atEof = false; @@ -130,20 +133,35 @@ this.first = first; } - // applies filter and also ignores "." and ".." + // ignores "." and ".." + private boolean ignore(String fileName) { + return (fileName.equals(".") || fileName.equals("..")); + } + // applies filter private Path acceptEntry(String s, BasicFileAttributes attrs) { - if (s.equals(".") || s.equals("..")) - return null; - if (dir.needsSlashWhenResolving()) { - StringBuilder sb = new StringBuilder(dir.toString()); - sb.append('\\'); - sb.append(s); - s = sb.toString(); - } else { - s = dir + s; + if (prefix == null) { + prefix = new StringBuilder(dir.toString()); + if (dir.needsSlashWhenResolving()) { + prefix.append('\\'); + } + fileSystem = dir.getFileSystem(); + prefixLength = prefix.length(); } + prefix.append(s); + String fullName = prefix.toString(); + prefix.setLength(prefixLength); +// System.out.println("***"); + +// if (dir.needsSlashWhenResolving()) { +// StringBuilder sb = new StringBuilder(dir.toString()); +// sb.append('\\'); +// sb.append(s); +// s = sb.toString(); +// } else { +// s = dir + s; +// } Path entry = WindowsPath - .createFromNormalizedPath(dir.getFileSystem(), s, attrs); + .createFromNormalizedPath(dir, fullName, s, attrs); try { if (filter.accept(entry)) return entry; @@ -157,7 +175,11 @@ private Path readNextEntry() { // handle first element returned by search if (first != null) { - nextEntry = acceptEntry(first, null); + if (ignore(first)) { + nextEntry = null; + } else { + nextEntry = acceptEntry(first, null); + } first = null; if (nextEntry != null) return nextEntry; @@ -184,6 +206,9 @@ return null; } + if (ignore(name)) { + continue; + } // grab the attributes from the WIN32_FIND_DATA structure // (needs to be done while holding closeLock because close // will release the buffer)