Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
4ff4b517
D
dragonwell11
项目概览
openanolis
/
dragonwell11
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4ff4b517
编写于
1月 31, 2018
作者:
S
serb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8191239: Improve desktop file usage
Reviewed-by: prr, rhalade, aghaisas
上级
5dd755b4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
21 deletion
+31
-21
src/java.desktop/macosx/classes/com/apple/eio/FileManager.java
...ava.desktop/macosx/classes/com/apple/eio/FileManager.java
+3
-3
src/java.desktop/share/classes/java/awt/Desktop.java
src/java.desktop/share/classes/java/awt/Desktop.java
+28
-18
未找到文件。
src/java.desktop/macosx/classes/com/apple/eio/FileManager.java
浏览文件 @
4ff4b517
/*
* Copyright (c) 2011, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 201
8
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -364,11 +364,11 @@ public class FileManager {
* @since Java for Mac OS X 10.5 Update 6 - 1.6, 1.5
*/
public
static
boolean
moveToTrash
(
final
File
file
)
throws
FileNotFoundException
{
if
(
file
==
null
||
!
file
.
exists
()
)
throw
new
FileNotFoundException
();
if
(
file
==
null
)
throw
new
FileNotFoundException
();
final
String
fileName
=
file
.
getAbsolutePath
();
final
SecurityManager
security
=
System
.
getSecurityManager
();
if
(
security
!=
null
)
security
.
check
Wri
te
(
fileName
);
if
(
security
!=
null
)
security
.
check
Dele
te
(
fileName
);
return
_moveToTrash
(
fileName
);
}
...
...
src/java.desktop/share/classes/java/awt/Desktop.java
浏览文件 @
4ff4b517
/*
* Copyright (c) 2005, 201
7
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
8
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -42,6 +42,9 @@ import java.io.FilePermission;
import
java.io.IOException
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.net.URL
;
import
java.security.AccessController
;
import
java.security.PrivilegedAction
;
import
java.util.Objects
;
import
javax.swing.JMenuBar
;
...
...
@@ -363,15 +366,11 @@ public class Desktop {
* @throws NullPointerException if file is null
* @throws IllegalArgumentException if file doesn't exist
*/
private
static
void
checkFileValidation
(
File
file
){
if
(
file
==
null
)
throw
new
NullPointerException
(
"File must not be null"
);
private
static
void
checkFileValidation
(
File
file
)
{
if
(!
file
.
exists
())
{
throw
new
IllegalArgumentException
(
"The file: "
+
file
.
getPath
()
+
" doesn't exist."
);
}
file
.
canRead
();
}
/**
...
...
@@ -425,6 +424,7 @@ public class Desktop {
* @see java.awt.AWTPermission
*/
public
void
open
(
File
file
)
throws
IOException
{
file
=
new
File
(
file
.
getPath
());
checkAWTPermission
();
checkExec
();
checkActionSupport
(
Action
.
OPEN
);
...
...
@@ -456,6 +456,7 @@ public class Desktop {
* @see java.awt.AWTPermission
*/
public
void
edit
(
File
file
)
throws
IOException
{
file
=
new
File
(
file
.
getPath
());
checkAWTPermission
();
checkExec
();
checkActionSupport
(
Action
.
EDIT
);
...
...
@@ -486,6 +487,7 @@ public class Desktop {
* allowed to create a subprocess
*/
public
void
print
(
File
file
)
throws
IOException
{
file
=
new
File
(
file
.
getPath
());
checkExec
();
SecurityManager
sm
=
System
.
getSecurityManager
();
if
(
sm
!=
null
)
{
...
...
@@ -614,14 +616,6 @@ public class Desktop {
}
}
private
void
checkDelete
()
throws
SecurityException
{
SecurityManager
sm
=
System
.
getSecurityManager
();
if
(
sm
!=
null
)
{
sm
.
checkPermission
(
new
FilePermission
(
"<<ALL FILES>>"
,
SecurityConstants
.
FILE_DELETE_ACTION
));
}
}
private
void
checkQuitPermission
()
{
SecurityManager
sm
=
System
.
getSecurityManager
();
if
(
sm
!=
null
)
{
...
...
@@ -950,6 +944,8 @@ public class Desktop {
* @since 9
*/
public
void
openHelpViewer
()
{
checkAWTPermission
();
checkExec
();
checkEventsProcessingPermission
();
checkActionSupport
(
Action
.
APP_HELP_VIEWER
);
peer
.
openHelpViewer
();
...
...
@@ -995,9 +991,15 @@ public class Desktop {
* @since 9
*/
public
void
browseFileDirectory
(
File
file
)
{
checkRead
();
file
=
new
File
(
file
.
getPath
());
checkAWTPermission
();
checkExec
();
checkActionSupport
(
Action
.
BROWSE_FILE_DIR
);
checkFileValidation
(
file
);
File
parentFile
=
file
.
getParentFile
();
if
(
parentFile
==
null
||
!
parentFile
.
exists
())
{
throw
new
IllegalArgumentException
(
"Parent folder doesn't exist"
);
}
peer
.
browseFileDirectory
(
file
);
}
...
...
@@ -1017,10 +1019,18 @@ public class Desktop {
*
* @since 9
*/
public
boolean
moveToTrash
(
final
File
file
)
{
checkDelete
();
public
boolean
moveToTrash
(
File
file
)
{
file
=
new
File
(
file
.
getPath
());
SecurityManager
sm
=
System
.
getSecurityManager
();
if
(
sm
!=
null
)
{
sm
.
checkDelete
(
file
.
getPath
());
}
checkActionSupport
(
Action
.
MOVE_TO_TRASH
);
checkFileValidation
(
file
);
final
File
finalFile
=
file
;
AccessController
.
doPrivileged
((
PrivilegedAction
<?>)
()
->
{
checkFileValidation
(
finalFile
);
return
null
;
});
return
peer
.
moveToTrash
(
file
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录