On windows!
Suppose I have a folder "test" containing two files, one standard file.txt, and second a junction point (created by sysinternals junction.exe) to the first file (created junction.exe filejunction file.txt). Here is "dir" executed in the folder:
{quote}
19.01.2015 23:58 0 file.txt
20.01.2015 00:03 <JUNCTION> filejunction [\??\c:\test\file.txt]
{quote}
The following code:
{code:java}
File f = new File("c:\\test\\filejunction");
Path p = f.toPath();
Files.walkFileTree(p.getParent(), new SimpleFileVisitor<Path>(){});
{code}
{quote}
java.nio.file.NotDirectoryException: c:\test\filejunction
at sun.nio.fs.WindowsDirectoryStream.<init>(WindowsDirectoryStream.java:84)
at sun.nio.fs.WindowsFileSystemProvider.newDirectoryStream(WindowsFileSystemProvider.java:510)
at java.nio.file.Files.newDirectoryStream(Files.java:457)
at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:300)
at java.nio.file.FileTreeWalker.next(FileTreeWalker.java:372)
at java.nio.file.Files.walkFileTree(Files.java:2703)
at java.nio.file.Files.walkFileTree(Files.java:2739)
{quote}
It appears there is something wrong with attributes. The method FileTreeWalker#visit contains:
{code:java}
if (depth >= maxDepth || !attrs.isDirectory()) {
return new Event(EventType.ENTRY, entry, attrs);
}
{code}
and WindowsFileAttributes#isDirectory contains:
{code:java}
return ((fileAttrs & FILE_ATTRIBUTE_DIRECTORY) != 0)
{code}
hence in this case: return ((fileAttrs = 1040) & 16) !=0 which is true.
It can be problem with attributes caching (in BasicFileAttributesHolder), because the following code returns {{false}}:
{code:java}
BasicFileAttributes attr = Files.readAttributes(p, BasicFileAttributes.class);
attr.isDirectory()
{code}
Suppose I have a folder "test" containing two files, one standard file.txt, and second a junction point (created by sysinternals junction.exe) to the first file (created junction.exe filejunction file.txt). Here is "dir" executed in the folder:
{quote}
19.01.2015 23:58 0 file.txt
20.01.2015 00:03 <JUNCTION> filejunction [\??\c:\test\file.txt]
{quote}
The following code:
{code:java}
File f = new File("c:\\test\\filejunction");
Path p = f.toPath();
Files.walkFileTree(p.getParent(), new SimpleFileVisitor<Path>(){});
{code}
{quote}
java.nio.file.NotDirectoryException: c:\test\filejunction
at sun.nio.fs.WindowsDirectoryStream.<init>(WindowsDirectoryStream.java:84)
at sun.nio.fs.WindowsFileSystemProvider.newDirectoryStream(WindowsFileSystemProvider.java:510)
at java.nio.file.Files.newDirectoryStream(Files.java:457)
at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:300)
at java.nio.file.FileTreeWalker.next(FileTreeWalker.java:372)
at java.nio.file.Files.walkFileTree(Files.java:2703)
at java.nio.file.Files.walkFileTree(Files.java:2739)
{quote}
It appears there is something wrong with attributes. The method FileTreeWalker#visit contains:
{code:java}
if (depth >= maxDepth || !attrs.isDirectory()) {
return new Event(EventType.ENTRY, entry, attrs);
}
{code}
and WindowsFileAttributes#isDirectory contains:
{code:java}
return ((fileAttrs & FILE_ATTRIBUTE_DIRECTORY) != 0)
{code}
hence in this case: return ((fileAttrs = 1040) & 16) !=0 which is true.
It can be problem with attributes caching (in BasicFileAttributesHolder), because the following code returns {{false}}:
{code:java}
BasicFileAttributes attr = Files.readAttributes(p, BasicFileAttributes.class);
attr.isDirectory()
{code}
- links to
-
Review(master) openjdk/jdk/21555