Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
0b7a6640
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看板
提交
0b7a6640
编写于
9月 10, 2009
作者:
B
bae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6631533: ICC_Profile allows detecting if some files exist
Reviewed-by: prr, hawtin
上级
3c4bc4cd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
96 addition
and
62 deletion
+96
-62
src/share/classes/java/awt/color/ICC_Profile.java
src/share/classes/java/awt/color/ICC_Profile.java
+96
-62
未找到文件。
src/share/classes/java/awt/color/ICC_Profile.java
浏览文件 @
0b7a6640
...
...
@@ -863,7 +863,9 @@ public class ICC_Profile implements Serializable {
case
ColorSpace
.
CS_PYCC
:
synchronized
(
ICC_Profile
.
class
)
{
if
(
PYCCprofile
==
null
)
{
if
(
getProfileFile
(
"PYCC.pf"
)
!=
null
)
{
if
(!
sun
.
jkernel
.
DownloadManager
.
isJREComplete
()
||
standardProfileExists
(
"PYCC.pf"
))
{
ProfileDeferralInfo
pInfo
=
new
ProfileDeferralInfo
(
"PYCC.pf"
,
ColorSpace
.
TYPE_3CLR
,
3
,
...
...
@@ -961,15 +963,15 @@ public class ICC_Profile implements Serializable {
* and it does not permit read access to the given file.
*/
public
static
ICC_Profile
getInstance
(
String
fileName
)
throws
IOException
{
ICC_Profile
thisProfile
;
FileInputStream
fis
;
ICC_Profile
thisProfile
;
FileInputStream
fis
=
null
;
SecurityManager
security
=
System
.
getSecurityManager
();
if
(
security
!=
null
)
{
security
.
checkRead
(
fileName
);
}
if
((
fis
=
openProfile
(
fileName
))
==
null
)
{
File
f
=
getProfileFile
(
fileName
);
if
(
f
!=
null
)
{
fis
=
new
FileInputStream
(
f
);
}
if
(
fis
==
null
)
{
throw
new
IOException
(
"Cannot open file "
+
fileName
);
}
...
...
@@ -1081,11 +1083,22 @@ public class ICC_Profile implements Serializable {
void
activateDeferredProfile
()
throws
ProfileDataException
{
byte
profileData
[];
FileInputStream
fis
;
String
fileName
=
deferralInfo
.
filename
;
final
String
fileName
=
deferralInfo
.
filename
;
profileActivator
=
null
;
deferralInfo
=
null
;
if
((
fis
=
openProfile
(
fileName
))
==
null
)
{
PrivilegedAction
<
FileInputStream
>
pa
=
new
PrivilegedAction
<
FileInputStream
>()
{
public
FileInputStream
run
()
{
File
f
=
getStandardProfileFile
(
fileName
);
if
(
f
!=
null
)
{
try
{
return
new
FileInputStream
(
f
);
}
catch
(
FileNotFoundException
e
)
{}
}
return
null
;
}
};
if
((
fis
=
AccessController
.
doPrivileged
(
pa
))
==
null
)
{
throw
new
ProfileDataException
(
"Cannot open file "
+
fileName
);
}
try
{
...
...
@@ -1784,86 +1797,107 @@ public class ICC_Profile implements Serializable {
* available, such as a profile for sRGB. Built-in profiles use .pf as
* the file name extension for profiles, e.g. sRGB.pf.
*/
private
static
FileInputStream
openProfile
(
final
String
fileName
)
{
return
(
FileInputStream
)
java
.
security
.
AccessController
.
doPrivileged
(
new
java
.
security
.
PrivilegedAction
()
{
public
Object
run
()
{
File
f
=
privilegedGetProfileFile
(
fileName
);
if
(
f
!=
null
)
{
try
{
return
new
FileInputStream
(
f
);
}
catch
(
FileNotFoundException
e
)
{
}
}
return
null
;
}
});
}
private
static
File
getProfileFile
(
final
String
fileName
)
{
return
(
File
)
java
.
security
.
AccessController
.
doPrivileged
(
new
java
.
security
.
PrivilegedAction
()
{
public
Object
run
()
{
return
privilegedGetProfileFile
(
fileName
);
}
});
}
/*
* this version is called from doPrivileged in openProfile
* or getProfileFile, so the whole method is privileged!
*/
private
static
File
privilegedGetProfileFile
(
String
fileName
)
{
private
static
File
getProfileFile
(
String
fileName
)
{
String
path
,
dir
,
fullPath
;
File
f
=
new
File
(
fileName
);
/* try absolute file name */
if
(
f
.
isAbsolute
())
{
/* Rest of code has little sense for an absolute pathname,
so return here. */
return
f
.
isFile
()
?
f
:
null
;
}
if
((!
f
.
isFile
())
&&
((
path
=
System
.
getProperty
(
"java.iccprofile.path"
))
!=
null
)){
/* try relative to java.iccprofile.path */
StringTokenizer
st
=
new
StringTokenizer
(
path
,
File
.
pathSeparator
);
while
(
st
.
hasMoreTokens
()
&&
(
!
f
.
isFile
(
)))
{
while
(
st
.
hasMoreTokens
()
&&
(
(
f
==
null
)
||
(!
f
.
isFile
()
)))
{
dir
=
st
.
nextToken
();
fullPath
=
dir
+
File
.
separatorChar
+
fileName
;
f
=
new
File
(
fullPath
);
if
(!
isChildOf
(
f
,
dir
))
{
f
=
null
;
}
}
}
if
((
!
f
.
isFile
(
))
&&
if
((
(
f
==
null
)
||
(!
f
.
isFile
()
))
&&
((
path
=
System
.
getProperty
(
"java.class.path"
))
!=
null
))
{
/* try relative to java.class.path */
StringTokenizer
st
=
new
StringTokenizer
(
path
,
File
.
pathSeparator
);
while
(
st
.
hasMoreTokens
()
&&
(
!
f
.
isFile
(
)))
{
while
(
st
.
hasMoreTokens
()
&&
(
(
f
==
null
)
||
(!
f
.
isFile
()
)))
{
dir
=
st
.
nextToken
();
fullPath
=
dir
+
File
.
separatorChar
+
fileName
;
f
=
new
File
(
fullPath
);
if
(!
isChildOf
(
f
,
dir
))
{
f
=
null
;
}
}
}
if
(!
f
.
isFile
())
{
/* try the directory of built-in profiles */
dir
=
System
.
getProperty
(
"java.home"
)
+
File
.
separatorChar
+
"lib"
+
File
.
separatorChar
+
"cmm"
;
fullPath
=
dir
+
File
.
separatorChar
+
fileName
;
f
=
new
File
(
fullPath
);
if
(!
f
.
isFile
())
{
//make sure file was installed in the kernel mode
try
{
//kernel uses platform independent paths =>
// should not use platform separator char
sun
.
jkernel
.
DownloadManager
.
downloadFile
(
"lib/cmm/"
+
fileName
);
}
catch
(
IOException
ioe
)
{}
}
}
if
(
f
.
isFile
())
{
if
((
f
==
null
)
||
(!
f
.
isFile
()))
{
/* try the directory of built-in profiles */
f
=
getStandardProfileFile
(
fileName
);
}
if
(
f
!=
null
&&
f
.
isFile
())
{
return
f
;
}
return
null
;
}
/**
* Returns a file object corresponding to a built-in profile
* specified by fileName.
* If there is no built-in profile with such name, then the method
* returns null.
*/
private
static
File
getStandardProfileFile
(
String
fileName
)
{
String
dir
=
System
.
getProperty
(
"java.home"
)
+
File
.
separatorChar
+
"lib"
+
File
.
separatorChar
+
"cmm"
;
String
fullPath
=
dir
+
File
.
separatorChar
+
fileName
;
File
f
=
new
File
(
fullPath
);
if
(!
f
.
isFile
())
{
//make sure file was installed in the kernel mode
try
{
//kernel uses platform independent paths =>
// should not use platform separator char
sun
.
jkernel
.
DownloadManager
.
downloadFile
(
"lib/cmm/"
+
fileName
);
}
catch
(
IOException
ioe
)
{}
}
return
(
f
.
isFile
()
&&
isChildOf
(
f
,
dir
))
?
f
:
null
;
}
/**
* Checks whether given file resides inside give directory.
*/
private
static
boolean
isChildOf
(
File
f
,
String
dirName
)
{
try
{
File
dir
=
new
File
(
dirName
);
String
canonicalDirName
=
dir
.
getCanonicalPath
();
if
(!
canonicalDirName
.
endsWith
(
File
.
separator
))
{
canonicalDirName
+=
File
.
separator
;
}
String
canonicalFileName
=
f
.
getCanonicalPath
();
return
canonicalFileName
.
startsWith
(
canonicalDirName
);
}
catch
(
IOException
e
)
{
/* we do not expect the IOException here, because invocation
* of this function is always preceeded by isFile() call.
*/
return
false
;
}
}
/**
* Checks whether built-in profile specified by fileName exists.
*/
private
static
boolean
standardProfileExists
(
final
String
fileName
)
{
return
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Boolean
>()
{
public
Boolean
run
()
{
return
getStandardProfileFile
(
fileName
)
!=
null
;
}
});
}
/*
* Serialization support.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录