提交 a82c3326 编写于 作者: A alanb

7016704: TEST_BUG: java/nio/file/Files/walk_file_tree.sh fails with new version of find (lnx)

Reviewed-by: forax
上级 53ed3e7c
...@@ -54,6 +54,7 @@ public class PrintFileTree { ...@@ -54,6 +54,7 @@ public class PrintFileTree {
if (followLinks) if (followLinks)
options.add(FileVisitOption.FOLLOW_LINKS); options.add(FileVisitOption.FOLLOW_LINKS);
final boolean follow = followLinks;
final boolean reportCycles = printCycles; final boolean reportCycles = printCycles;
Files.walkFileTree(dir, options, Integer.MAX_VALUE, new FileVisitor<Path>() { Files.walkFileTree(dir, options, Integer.MAX_VALUE, new FileVisitor<Path>() {
@Override @Override
...@@ -63,8 +64,7 @@ public class PrintFileTree { ...@@ -63,8 +64,7 @@ public class PrintFileTree {
} }
@Override @Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
if (!attrs.isDirectory() || reportCycles) System.out.println(file);
System.out.println(file);
return FileVisitResult.CONTINUE; return FileVisitResult.CONTINUE;
} }
@Override @Override
...@@ -79,11 +79,13 @@ public class PrintFileTree { ...@@ -79,11 +79,13 @@ public class PrintFileTree {
public FileVisitResult visitFileFailed(Path file, IOException exc) public FileVisitResult visitFileFailed(Path file, IOException exc)
throws IOException throws IOException
{ {
if (reportCycles && (exc instanceof FileSystemLoopException)) { if (follow && (exc instanceof FileSystemLoopException)) {
System.out.println(file); if (reportCycles)
System.out.println(file);
return FileVisitResult.CONTINUE; return FileVisitResult.CONTINUE;
} else {
throw exc;
} }
throw exc;
} }
}); });
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册