Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
3145b078
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3145b078
编写于
2月 23, 2010
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6926800: TEST_BUG: java/nio/file/Files/walk_file_tree.sh fails with newer versions of find(1)
Reviewed-by: forax
上级
3e2533e1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
15 deletion
+30
-15
test/java/nio/file/Files/PrintFileTree.java
test/java/nio/file/Files/PrintFileTree.java
+17
-10
test/java/nio/file/Files/walk_file_tree.sh
test/java/nio/file/Files/walk_file_tree.sh
+13
-5
未找到文件。
test/java/nio/file/Files/PrintFileTree.java
浏览文件 @
3145b078
...
...
@@ -28,27 +28,33 @@ import java.util.*;
/**
* Invokes Files.walkFileTree to traverse a file tree and prints
* each of the directories and files. The -L option causes symbolic
* links to be followed.
* each of the directories and files. The -follow option causes symbolic
* links to be followed and the -printCycles option will print links
* where the target of the link is an ancestor directory.
*/
public
class
PrintFileTree
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
boolean
followLinks
=
false
;
Path
dir
;
if
(
args
[
0
].
equals
(
"-L"
))
{
followLinks
=
true
;
dir
=
Paths
.
get
(
args
[
1
]);
}
else
{
dir
=
Paths
.
get
(
args
[
0
]);
boolean
printCycles
=
false
;
int
i
=
0
;
while
(
i
<
(
args
.
length
-
1
))
{
switch
(
args
[
i
])
{
case
"-follow"
:
followLinks
=
true
;
break
;
case
"-printCycles"
:
printCycles
=
true
;
break
;
default
:
throw
new
RuntimeException
(
args
[
i
]
+
" not recognized"
);
}
i
++;
}
Path
dir
=
Paths
.
get
(
args
[
i
]);
Set
<
FileVisitOption
>
options
=
new
HashSet
<
FileVisitOption
>();
if
(
followLinks
)
options
.
add
(
FileVisitOption
.
FOLLOW_LINKS
);
final
boolean
reportCycles
=
printCycles
;
Files
.
walkFileTree
(
dir
,
options
,
Integer
.
MAX_VALUE
,
new
FileVisitor
<
FileRef
>()
{
public
FileVisitResult
preVisitDirectory
(
FileRef
dir
)
{
System
.
out
.
println
(
dir
);
...
...
@@ -59,7 +65,8 @@ public class PrintFileTree {
return
FileVisitResult
.
CONTINUE
;
}
public
FileVisitResult
visitFile
(
FileRef
file
,
BasicFileAttributes
attrs
)
{
System
.
out
.
println
(
file
);
if
(!
attrs
.
isDirectory
()
||
reportCycles
)
System
.
out
.
println
(
file
);
return
FileVisitResult
.
CONTINUE
;
}
public
FileVisitResult
postVisitDirectory
(
FileRef
dir
,
IOException
exc
)
{
...
...
test/java/nio/file/Files/walk_file_tree.sh
浏览文件 @
3145b078
...
...
@@ -61,12 +61,20 @@ find "$ROOT" > out2
diff out1 out2
if
[
$?
!=
0
]
;
then
failures
=
`
expr
$failures
+ 1
`
;
fi
# repeat test following links (use -follow instead of -L
# to allow running on older systems)
$JAVA
PrintFileTree
-L
"
$ROOT
"
>
out1
find
"
$ROOT
"
-follow
>
out2
# repeat test following links. Some versions of find(1) output
# cycles (sym links to ancestor directories), other versions do
# not. For that reason we run PrintFileTree with the -printCycles
# option when the output without this option differs to find(1).
find
"
$ROOT
"
-follow
>
out1
$JAVA
PrintFileTree
-follow
"
$ROOT
"
>
out2
diff out1 out2
if
[
$?
!=
0
]
;
then
failures
=
`
expr
$failures
+ 1
`
;
fi
if
[
$?
!=
0
]
;
then
# re-run printing cycles to stdout
$JAVA
PrintFileTree
-follow
-printCycles
"
$ROOT
"
>
out2
diff out1 out2
if
[
$?
!=
0
]
;
then
failures
=
`
expr
$failures
+ 1
`
;
fi
fi
# test SKIP_SIBLINGS
$JAVA
SkipSiblings
"
$ROOT
"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录