Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
2aae5ac1
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看板
提交
2aae5ac1
编写于
6月 25, 2008
作者:
T
tbell
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
b496f70b
09296ee2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
108 addition
and
35 deletion
+108
-35
src/share/classes/java/nio/charset/Charset.java
src/share/classes/java/nio/charset/Charset.java
+11
-10
src/windows/native/java/io/io_util_md.c
src/windows/native/java/io/io_util_md.c
+41
-25
test/java/io/File/MaxPath.java
test/java/io/File/MaxPath.java
+56
-0
未找到文件。
src/share/classes/java/nio/charset/Charset.java
浏览文件 @
2aae5ac1
...
...
@@ -188,21 +188,22 @@ import sun.security.action.GetPropertyAction;
* <ul>
*
* <li><p> When decoding, the <tt>UTF-16BE</tt> and <tt>UTF-16LE</tt>
* charsets ignore byte-order marks; when encoding, they do not write
* charsets interpret the initial byte-order marks as a <small>ZERO-WIDTH
* NON-BREAKING SPACE</small>; when encoding, they do not write
* byte-order marks. </p></li>
*
* <li><p> When decoding, the <tt>UTF-16</tt> charset interprets a byte-order
* mark to indicate the byte order of the stream but defaults to big-endian
* if there is no byte-order mark; when encoding, it uses big-endian byte
* order and writes a big-endian byte-order mark. </p></li>
* <li><p> When decoding, the <tt>UTF-16</tt> charset interprets the
* byte-order mark at the beginning of the input stream to indicate the
* byte-order of the stream but defaults to big-endian if there is no
* byte-order mark; when encoding, it uses big-endian byte order and writes
* a big-endian byte-order mark. </p></li>
*
* </ul>
*
* In any case, when a byte-order mark is read at the beginning of a decoding
* operation it is omitted from the resulting sequence of characters. Byte
* order marks occuring after the first element of an input sequence are not
* omitted since the same code is used to represent <small>ZERO-WIDTH
* NON-BREAKING SPACE</small>.
* In any case, byte order marks occuring after the first element of an
* input sequence are not omitted since the same code is used to represent
* <small>ZERO-WIDTH NON-BREAKING SPACE</small>.
*
* <p> Every instance of the Java virtual machine has a default charset, which
* may or may not be one of the standard charsets. The default charset is
...
...
src/windows/native/java/io/io_util_md.c
浏览文件 @
2aae5ac1
...
...
@@ -104,23 +104,56 @@ currentDirLength(const WCHAR* ps, int pathlen) {
}
}
/*
The "abpathlen" is the size of the buffer needed by _wfullpath. If the
"path" is a relative path, it is "the length of the current dir" + "the
length of the path", if it's "absolute" already, it's the same as
pathlen which is the length of "path".
*/
WCHAR
*
prefixAbpath
(
const
WCHAR
*
path
,
int
pathlen
,
int
abpathlen
)
{
WCHAR
*
pathbuf
=
NULL
;
WCHAR
*
abpath
=
NULL
;
abpathlen
+=
10
;
//padding
abpath
=
(
WCHAR
*
)
malloc
(
abpathlen
*
sizeof
(
WCHAR
));
if
(
abpath
)
{
/* Collapse instances of "foo\.." and ensure absoluteness before
going down to prefixing.
*/
if
(
_wfullpath
(
abpath
,
path
,
abpathlen
))
{
pathbuf
=
getPrefixed
(
abpath
,
abpathlen
);
}
else
{
/* _wfullpath fails if the pathlength exceeds 32k wchar.
Instead of doing more fancy things we simply copy the
ps into the return buffer, the subsequent win32 API will
probably fail with FileNotFoundException, which is expected
*/
pathbuf
=
(
WCHAR
*
)
malloc
((
pathlen
+
6
)
*
sizeof
(
WCHAR
));
if
(
pathbuf
!=
0
)
{
wcscpy
(
pathbuf
,
path
);
}
}
free
(
abpath
);
}
return
pathbuf
;
}
/* If this returns NULL then an exception is pending */
WCHAR
*
pathToNTPath
(
JNIEnv
*
env
,
jstring
path
,
jboolean
throwFNFE
)
{
int
pathlen
=
0
;
WCHAR
*
pathbuf
=
NULL
;
int
max_path
=
248
;
/* Since CreateDirectoryW() has the limit of
248 instead of the normal MAX_PATH, we
use 248 as the max_path to satisfy both
*/
int
max_path
=
248
;
/* CreateDirectoryW() has the limit of 248 */
WITH_UNICODE_STRING
(
env
,
path
,
ps
)
{
pathlen
=
wcslen
(
ps
);
if
(
pathlen
!=
0
)
{
if
(
pathlen
>
2
&&
(
ps
[
0
]
==
L'\\'
&&
ps
[
1
]
==
L'\\'
||
//UNC
ps
[
1
]
==
L':'
&&
ps
[
2
]
==
L'\\'
))
{
//absolute
ps
[
1
]
==
L':'
&&
ps
[
2
]
==
L'\\'
))
//absolute
{
if
(
pathlen
>
max_path
-
1
)
{
pathbuf
=
getPrefixed
(
ps
,
pathlen
);
pathbuf
=
prefixAbpath
(
ps
,
pathlen
,
pathlen
);
}
else
{
pathbuf
=
(
WCHAR
*
)
malloc
((
pathlen
+
6
)
*
sizeof
(
WCHAR
));
if
(
pathbuf
!=
0
)
{
...
...
@@ -132,7 +165,7 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) {
its absolute form is bigger than max_path or not, if yes
need to (1)convert it to absolute and (2)prefix. This is
obviously a burden to all relative paths (The current dir/len
for "d
ir
ve & directory" relative path is cached, so we only
for "d
ri
ve & directory" relative path is cached, so we only
calculate it once but for "drive-relative path we call
_wgetdcwd() and wcslen() everytime), but a hit we have
to take if we want to support relative path beyond max_path.
...
...
@@ -143,24 +176,7 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) {
WCHAR
*
abpath
=
NULL
;
int
dirlen
=
currentDirLength
(
ps
,
pathlen
);
if
(
dirlen
+
pathlen
+
1
>
max_path
-
1
)
{
int
abpathlen
=
dirlen
+
pathlen
+
10
;
abpath
=
(
WCHAR
*
)
malloc
(
abpathlen
*
sizeof
(
WCHAR
));
if
(
abpath
)
{
if
(
_wfullpath
(
abpath
,
ps
,
abpathlen
))
{
pathbuf
=
getPrefixed
(
abpath
,
abpathlen
);
}
else
{
/* _wfullpath fails if the pathlength exceeds 32k wchar.
Instead of doing more fancy things we simply copy the
ps into the return buffer, the subsequent win32 API will
probably fail with FileNotFoundException, which is expected
*/
pathbuf
=
(
WCHAR
*
)
malloc
((
pathlen
+
6
)
*
sizeof
(
WCHAR
));
if
(
pathbuf
!=
0
)
{
wcscpy
(
pathbuf
,
ps
);
}
}
free
(
abpath
);
}
pathbuf
=
prefixAbpath
(
ps
,
pathlen
,
dirlen
+
pathlen
);
}
else
{
pathbuf
=
(
WCHAR
*
)
malloc
((
pathlen
+
6
)
*
sizeof
(
WCHAR
));
if
(
pathbuf
!=
0
)
{
...
...
test/java/io/File/MaxPath.java
0 → 100644
浏览文件 @
2aae5ac1
/*
* Copyright 2008 Sun Microsystems, Inc. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
@bug 6481955
@summary Path length less than MAX_PATH (260) works on Windows
*/
import
java.io.*
;
public
class
MaxPath
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
osName
=
System
.
getProperty
(
"os.name"
);
if
(!
osName
.
startsWith
(
"Windows"
))
{
return
;
}
int
MAX_PATH
=
260
;
String
dir
=
new
File
(
"."
).
getAbsolutePath
()
+
"\\"
;
String
padding
=
"1234567890123456789012345678901234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890"
;
for
(
int
i
=
240
-
dir
.
length
();
i
<
MAX_PATH
-
dir
.
length
();
i
++)
{
String
longname
=
dir
+
padding
.
substring
(
0
,
i
);
try
{
File
f
=
new
File
(
longname
);
if
(
f
.
createNewFile
())
{
if
(!
f
.
exists
()
||
!
f
.
canRead
())
{
throw
new
RuntimeException
(
"Failed at length: "
+
longname
.
length
());
}
f
.
delete
();
}
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"Failed at length: "
+
longname
.
length
());
throw
e
;
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录