Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
842b3542
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
842b3542
编写于
4月 20, 2009
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6831461: (sample) Copy -r fails with IllegalArgumentexception: 'maxDepth' is negative
Reviewed-by: chegar
上级
c49a1fe6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
9 addition
and
6 deletion
+9
-6
src/share/sample/nio/file/Copy.java
src/share/sample/nio/file/Copy.java
+9
-6
未找到文件。
src/share/sample/nio/file/Copy.java
浏览文件 @
842b3542
...
...
@@ -52,7 +52,7 @@ public class Copy {
/**
* Copy source file to target location. If {@code prompt} is true then
* prompt
ed
user to overwrite target if it exists. The {@code preserve}
* prompt user to overwrite target if it exists. The {@code preserve}
* parameter determines if file attributes should be copied/preserved.
*/
static
void
copyFile
(
Path
source
,
Path
target
,
boolean
prompt
,
boolean
preserve
)
{
...
...
@@ -63,7 +63,7 @@ public class Copy {
try
{
source
.
copyTo
(
target
,
options
);
}
catch
(
IOException
x
)
{
System
.
err
.
format
(
"Unable to c
reate: %s: %s%n"
,
target
,
x
);
System
.
err
.
format
(
"Unable to c
opy: %s: %s%n"
,
source
,
x
);
}
}
}
...
...
@@ -124,13 +124,13 @@ public class Copy {
public
FileVisitResult
postVisitDirectory
(
Path
dir
,
IOException
exc
)
{
// fix up modification time of directory when done
if
(
exc
==
null
&&
preserve
)
{
Path
newdir
=
target
.
resolve
(
source
.
relativize
(
dir
));
try
{
BasicFileAttributes
attrs
=
Attributes
.
readBasicFileAttributes
(
dir
);
Path
newdir
=
target
.
resolve
(
source
.
relativize
(
dir
));
Attributes
.
setLastModifiedTime
(
newdir
,
attrs
.
lastModifiedTime
(),
attrs
.
resolution
());
}
catch
(
IOException
x
)
{
// ignore
System
.
err
.
format
(
"Unable to copy all attributes to: %s: %s%n"
,
newdir
,
x
);
}
}
return
CONTINUE
;
...
...
@@ -191,6 +191,7 @@ public class Copy {
try
{
isDir
=
Attributes
.
readBasicFileAttributes
(
target
).
isDirectory
();
}
catch
(
IOException
x
)
{
// ignore (probably target does not exist)
}
// copy each source file/directory to target
...
...
@@ -201,7 +202,7 @@ public class Copy {
// follow links when copying files
EnumSet
<
FileVisitOption
>
opts
=
EnumSet
.
of
(
FileVisitOption
.
FOLLOW_LINKS
);
TreeCopier
tc
=
new
TreeCopier
(
source
[
i
],
dest
,
prompt
,
preserve
);
Files
.
walkFileTree
(
source
[
i
],
opts
,
-
1
,
tc
);
Files
.
walkFileTree
(
source
[
i
],
opts
,
Integer
.
MAX_VALUE
,
tc
);
}
else
{
// not recursive so source must not be a directory
try
{
...
...
@@ -209,7 +210,9 @@ public class Copy {
System
.
err
.
format
(
"%s: is a directory%n"
,
source
[
i
]);
continue
;
}
}
catch
(
IOException
x
)
{
}
}
catch
(
IOException
x
)
{
// assume not directory
}
copyFile
(
source
[
i
],
dest
,
prompt
,
preserve
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录