Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
3bf81d3e
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看板
提交
3bf81d3e
编写于
5月 28, 2013
作者:
R
robm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7038105: File.isHidden() should return true for pagefile.sys and hiberfil.sys
Reviewed-by: alanb
上级
2d3972eb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
28 deletion
+43
-28
src/windows/native/java/io/WinNTFileSystem_md.c
src/windows/native/java/io/WinNTFileSystem_md.c
+32
-27
test/java/io/File/IsHidden.java
test/java/io/File/IsHidden.java
+11
-1
未找到文件。
src/windows/native/java/io/WinNTFileSystem_md.c
浏览文件 @
3bf81d3e
/*
/*
* Copyright (c) 2001, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -199,7 +199,7 @@ static BOOL getFileInformation(const WCHAR *path,
...
@@ -199,7 +199,7 @@ static BOOL getFileInformation(const WCHAR *path,
/**
/**
* If the given attributes are the attributes of a reparse point, then
* If the given attributes are the attributes of a reparse point, then
* read and return the attributes of the
final target
.
* read and return the attributes of the
special cases
.
*/
*/
DWORD
getFinalAttributesIfReparsePoint
(
WCHAR
*
path
,
DWORD
a
)
DWORD
getFinalAttributesIfReparsePoint
(
WCHAR
*
path
,
DWORD
a
)
{
{
...
@@ -213,6 +213,28 @@ DWORD getFinalAttributesIfReparsePoint(WCHAR *path, DWORD a)
...
@@ -213,6 +213,28 @@ DWORD getFinalAttributesIfReparsePoint(WCHAR *path, DWORD a)
return
a
;
return
a
;
}
}
/**
* Take special cases into account when retrieving the attributes
* of path
*/
DWORD
getFinalAttributes
(
WCHAR
*
path
)
{
DWORD
attr
=
INVALID_FILE_ATTRIBUTES
;
WIN32_FILE_ATTRIBUTE_DATA
wfad
;
WIN32_FIND_DATAW
wfd
;
HANDLE
h
;
if
(
GetFileAttributesExW
(
path
,
GetFileExInfoStandard
,
&
wfad
))
{
attr
=
getFinalAttributesIfReparsePoint
(
path
,
wfad
.
dwFileAttributes
);
}
else
if
(
GetLastError
()
==
ERROR_SHARING_VIOLATION
&&
(
h
=
FindFirstFileW
(
path
,
&
wfd
))
!=
INVALID_HANDLE_VALUE
)
{
attr
=
getFinalAttributesIfReparsePoint
(
path
,
wfd
.
dwFileAttributes
);
CloseHandle
(
h
);
}
return
attr
;
}
JNIEXPORT
jstring
JNICALL
JNIEXPORT
jstring
JNICALL
Java_java_io_WinNTFileSystem_canonicalize0
(
JNIEnv
*
env
,
jobject
this
,
Java_java_io_WinNTFileSystem_canonicalize0
(
JNIEnv
*
env
,
jobject
this
,
jstring
pathname
)
jstring
pathname
)
...
@@ -337,38 +359,21 @@ JNIEXPORT jint JNICALL
...
@@ -337,38 +359,21 @@ JNIEXPORT jint JNICALL
Java_java_io_WinNTFileSystem_getBooleanAttributes
(
JNIEnv
*
env
,
jobject
this
,
Java_java_io_WinNTFileSystem_getBooleanAttributes
(
JNIEnv
*
env
,
jobject
this
,
jobject
file
)
jobject
file
)
{
{
jint
rv
=
0
;
jint
rv
=
0
;
jint
pathlen
;
jint
pathlen
;
/* both pagefile.sys and hiberfil.sys have length 12 */
#define SPECIALFILE_NAMELEN 12
WCHAR
*
pathbuf
=
fileToNTPath
(
env
,
file
,
ids
.
path
);
WCHAR
*
pathbuf
=
fileToNTPath
(
env
,
file
,
ids
.
path
);
WIN32_FILE_ATTRIBUTE_DATA
wfad
;
if
(
pathbuf
==
NULL
)
if
(
pathbuf
==
NULL
)
return
rv
;
return
rv
;
if
(
!
isReservedDeviceNameW
(
pathbuf
))
{
if
(
!
isReservedDeviceNameW
(
pathbuf
))
{
if
(
GetFileAttributesExW
(
pathbuf
,
GetFileExInfoStandard
,
&
wfad
))
{
DWORD
a
=
getFinalAttributes
(
pathbuf
);
DWORD
a
=
getFinalAttributesIfReparsePoint
(
pathbuf
,
wfad
.
dwFileAttributes
);
if
(
a
!=
INVALID_FILE_ATTRIBUTES
)
{
if
(
a
!=
INVALID_FILE_ATTRIBUTES
)
{
rv
=
(
java_io_FileSystem_BA_EXISTS
rv
=
(
java_io_FileSystem_BA_EXISTS
|
((
a
&
FILE_ATTRIBUTE_DIRECTORY
)
|
((
a
&
FILE_ATTRIBUTE_DIRECTORY
)
?
java_io_FileSystem_BA_DIRECTORY
?
java_io_FileSystem_BA_DIRECTORY
:
java_io_FileSystem_BA_REGULAR
)
:
java_io_FileSystem_BA_REGULAR
)
|
((
a
&
FILE_ATTRIBUTE_HIDDEN
)
|
((
a
&
FILE_ATTRIBUTE_HIDDEN
)
?
java_io_FileSystem_BA_HIDDEN
:
0
));
?
java_io_FileSystem_BA_HIDDEN
:
0
));
}
}
else
{
/* pagefile.sys is a special case */
if
(
GetLastError
()
==
ERROR_SHARING_VIOLATION
)
{
rv
=
java_io_FileSystem_BA_EXISTS
;
if
((
pathlen
=
(
jint
)
wcslen
(
pathbuf
))
>=
SPECIALFILE_NAMELEN
&&
(
_wcsicmp
(
pathbuf
+
pathlen
-
SPECIALFILE_NAMELEN
,
L"pagefile.sys"
)
==
0
)
||
(
_wcsicmp
(
pathbuf
+
pathlen
-
SPECIALFILE_NAMELEN
,
L"hiberfil.sys"
)
==
0
))
rv
|=
java_io_FileSystem_BA_REGULAR
;
}
}
}
}
}
free
(
pathbuf
);
free
(
pathbuf
);
...
...
test/java/io/File/IsHidden.java
浏览文件 @
3bf81d3e
/*
/*
* Copyright (c) 1998, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -46,6 +46,11 @@ public class IsHidden {
...
@@ -46,6 +46,11 @@ public class IsHidden {
Files
.
getFileAttributeView
(
f
.
toPath
(),
DosFileAttributeView
.
class
).
setHidden
(
value
);
Files
.
getFileAttributeView
(
f
.
toPath
(),
DosFileAttributeView
.
class
).
setHidden
(
value
);
}
}
private
static
void
checkHidden
(
File
f
)
{
if
(!
f
.
isHidden
())
throw
new
RuntimeException
(
f
+
" should be hidden"
);
}
private
static
void
testWin32
()
throws
Exception
{
private
static
void
testWin32
()
throws
Exception
{
File
f
=
new
File
(
dir
,
"test"
);
File
f
=
new
File
(
dir
,
"test"
);
f
.
deleteOnExit
();
f
.
deleteOnExit
();
...
@@ -58,6 +63,11 @@ public class IsHidden {
...
@@ -58,6 +63,11 @@ public class IsHidden {
}
}
ck
(
".foo"
,
false
);
ck
(
".foo"
,
false
);
ck
(
"foo"
,
false
);
ck
(
"foo"
,
false
);
File
pagefile
=
new
File
(
"C:\\pagefile.sys"
);
File
hiberfil
=
new
File
(
"C:\\hiberfil.sys"
);
if
(
pagefile
.
exists
())
checkHidden
(
pagefile
);
if
(
hiberfil
.
exists
())
checkHidden
(
hiberfil
);
}
}
private
static
void
testUnix
()
throws
Exception
{
private
static
void
testUnix
()
throws
Exception
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录