Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
d26ad150
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看板
提交
d26ad150
编写于
1月 24, 2011
作者:
M
mullan
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
076c13a6
b2fd1c85
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
178 addition
and
169 deletion
+178
-169
src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java
...e/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java
+124
-162
src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipPath.java
src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipPath.java
+7
-2
test/demo/zipfs/PathOps.java
test/demo/zipfs/PathOps.java
+21
-1
test/demo/zipfs/ZipFSTester.java
test/demo/zipfs/ZipFSTester.java
+25
-3
test/demo/zipfs/basic.sh
test/demo/zipfs/basic.sh
+1
-1
未找到文件。
src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java
浏览文件 @
d26ad150
此差异已折叠。
点击以展开。
src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipPath.java
浏览文件 @
d26ad150
...
...
@@ -157,7 +157,7 @@ public class ZipPath extends Path {
@Override
public
ZipPath
toRealPath
(
boolean
resolveLinks
)
throws
IOException
{
ZipPath
realPath
=
new
ZipPath
(
zfs
,
getResolvedPath
());
ZipPath
realPath
=
new
ZipPath
(
zfs
,
getResolvedPath
())
.
toAbsolutePath
()
;
realPath
.
checkAccess
();
return
realPath
;
}
...
...
@@ -472,8 +472,11 @@ public class ZipPath extends Path {
int
n
=
offsets
[
i
];
int
len
=
(
i
==
offsets
.
length
-
1
)?
(
path
.
length
-
n
):(
offsets
[
i
+
1
]
-
n
-
1
);
if
(
len
==
1
&&
path
[
n
]
==
(
byte
)
'.'
)
if
(
len
==
1
&&
path
[
n
]
==
(
byte
)
'.'
)
{
if
(
m
==
0
&&
path
[
0
]
==
'/'
)
// absolute path
to
[
m
++]
=
'/'
;
continue
;
}
if
(
len
==
2
&&
path
[
n
]
==
'.'
&&
path
[
n
+
1
]
==
'.'
)
{
if
(
lastMOff
>=
0
)
{
m
=
lastM
[
lastMOff
--];
// retreat
...
...
@@ -726,6 +729,8 @@ public class ZipPath extends Path {
@Override
public
boolean
isSameFile
(
Path
other
)
throws
IOException
{
if
(
this
.
equals
(
other
))
return
true
;
if
(
other
==
null
||
this
.
getFileSystem
()
!=
other
.
getFileSystem
())
return
false
;
...
...
test/demo/zipfs/PathOps.java
浏览文件 @
d26ad150
...
...
@@ -193,6 +193,17 @@ public class PathOps {
return
this
;
}
PathOps
isSameFile
(
String
target
)
{
try
{
out
.
println
(
"check two paths are same"
);
checkPath
();
check
(
path
.
isSameFile
(
test
(
target
).
path
()),
true
);
}
catch
(
IOException
ioe
)
{
fail
();
}
return
this
;
}
PathOps
invalid
()
{
if
(!(
exc
instanceof
InvalidPathException
))
{
out
.
println
(
"InvalidPathException not thrown as expected"
);
...
...
@@ -344,7 +355,12 @@ public class PathOps {
.
normalize
(
"foo"
);
test
(
"/foo/bar/gus/../.."
)
.
normalize
(
"/foo"
);
test
(
"/./."
)
.
normalize
(
"/"
);
test
(
"/."
)
.
normalize
(
"/"
);
test
(
"/./abc"
)
.
normalize
(
"/abc"
);
// invalid
test
(
"foo\u0000bar"
)
.
invalid
();
...
...
@@ -365,6 +381,10 @@ public class PathOps {
.
root
(
"/"
)
.
parent
(
"/foo"
)
.
name
(
"bar"
);
// isSameFile
test
(
"/fileDoesNotExist"
)
.
isSameFile
(
"/fileDoesNotExist"
);
}
static
void
npes
()
{
...
...
test/demo/zipfs/ZipFSTester.java
浏览文件 @
d26ad150
...
...
@@ -28,6 +28,7 @@ import java.nio.file.*;
import
java.nio.file.attribute.*
;
import
java.net.*
;
import
java.util.*
;
import
java.util.zip.*
;
import
static
java
.
nio
.
file
.
StandardOpenOption
.*;
import
static
java
.
nio
.
file
.
StandardCopyOption
.*;
...
...
@@ -42,7 +43,8 @@ public class ZipFSTester {
FileSystem
fs
=
null
;
try
{
fs
=
newZipFileSystem
(
Paths
.
get
(
args
[
0
]),
new
HashMap
<
String
,
Object
>());
test
(
fs
);
test0
(
fs
);
test1
(
fs
);
test2
(
fs
);
// more tests
}
finally
{
if
(
fs
!=
null
)
...
...
@@ -50,11 +52,31 @@ public class ZipFSTester {
}
}
static
void
test
(
FileSystem
fs
)
static
void
test
0
(
FileSystem
fs
)
throws
Exception
{
Random
rdm
=
new
Random
();
List
<
String
>
list
=
new
LinkedList
<>();
try
(
ZipFile
zf
=
new
ZipFile
(
fs
.
toString
()))
{
Enumeration
<?
extends
ZipEntry
>
zes
=
zf
.
entries
();
while
(
zes
.
hasMoreElements
())
{
list
.
add
(
zes
.
nextElement
().
getName
());
}
for
(
String
pname
:
list
)
{
Path
path
=
fs
.
getPath
(
pname
);
if
(!
path
.
exists
())
throw
new
RuntimeException
(
"path existence check failed!"
);
while
((
path
=
path
.
getParent
())
!=
null
)
{
if
(!
path
.
exists
())
throw
new
RuntimeException
(
"parent existence check failed!"
);
}
}
}
}
static
void
test1
(
FileSystem
fs
)
throws
Exception
{
Random
rdm
=
new
Random
();
// clone a fs and test on it
Path
tmpfsPath
=
getTempPath
();
Map
<
String
,
Object
>
env
=
new
HashMap
<
String
,
Object
>();
...
...
test/demo/zipfs/basic.sh
浏览文件 @
d26ad150
...
...
@@ -21,7 +21,7 @@
# questions.
#
# @test
# @bug 6990846
# @bug 6990846
7009092 7009085
# @summary Test ZipFileSystem demo
# @build Basic PathOps ZipFSTester
# @run shell basic.sh
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录