Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
ac65d7c1
提交
ac65d7c1
authored
1月 07, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FileSystem improvements.
上级
d497e7d0
显示空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
32 行增加
和
46 行删除
+32
-46
FilePath.java
h2/src/main/org/h2/store/fs/FilePath.java
+1
-1
FilePathDisk.java
h2/src/main/org/h2/store/fs/FilePathDisk.java
+2
-7
FilePathMem.java
h2/src/main/org/h2/store/fs/FilePathMem.java
+4
-8
FilePathRec.java
h2/src/main/org/h2/store/fs/FilePathRec.java
+1
-1
FilePathSplit.java
h2/src/main/org/h2/store/fs/FilePathSplit.java
+2
-6
FilePathWrapper.java
h2/src/main/org/h2/store/fs/FilePathWrapper.java
+1
-1
FilePathZip.java
h2/src/main/org/h2/store/fs/FilePathZip.java
+2
-2
FileUtils.java
h2/src/main/org/h2/store/fs/FileUtils.java
+1
-1
TestFileSystem.java
h2/src/test/org/h2/test/unit/TestFileSystem.java
+7
-12
FilePathDebug.java
h2/src/test/org/h2/test/utils/FilePathDebug.java
+10
-6
FilePathUnstable.java
h2/src/test/org/h2/test/utils/FilePathUnstable.java
+1
-1
没有找到文件。
h2/src/main/org/h2/store/fs/FilePath.java
浏览文件 @
ac65d7c1
...
@@ -213,7 +213,7 @@ public abstract class FilePath {
...
@@ -213,7 +213,7 @@ public abstract class FilePath {
* truncated first
* truncated first
* @return the output stream
* @return the output stream
*/
*/
public
abstract
OutputStream
newOutputStream
(
boolean
append
);
public
abstract
OutputStream
newOutputStream
(
boolean
append
)
throws
IOException
;
/**
/**
* Open a random access file object.
* Open a random access file object.
...
...
h2/src/main/org/h2/store/fs/FilePathDisk.java
浏览文件 @
ac65d7c1
...
@@ -247,7 +247,7 @@ public class FilePathDisk extends FilePath {
...
@@ -247,7 +247,7 @@ public class FilePathDisk extends FilePath {
throw
DbException
.
get
(
ErrorCode
.
FILE_CREATION_FAILED_1
,
name
);
throw
DbException
.
get
(
ErrorCode
.
FILE_CREATION_FAILED_1
,
name
);
}
}
public
OutputStream
newOutputStream
(
boolean
append
)
{
public
OutputStream
newOutputStream
(
boolean
append
)
throws
IOException
{
try
{
try
{
File
file
=
new
File
(
name
);
File
file
=
new
File
(
name
);
File
parent
=
file
.
getParentFile
();
File
parent
=
file
.
getParentFile
();
...
@@ -259,11 +259,7 @@ public class FilePathDisk extends FilePath {
...
@@ -259,11 +259,7 @@ public class FilePathDisk extends FilePath {
return
out
;
return
out
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
freeMemoryAndFinalize
();
freeMemoryAndFinalize
();
try
{
return
new
FileOutputStream
(
name
);
return
new
FileOutputStream
(
name
);
}
catch
(
IOException
e2
)
{
throw
DbException
.
convertIOException
(
e
,
name
);
}
}
}
}
}
...
@@ -398,7 +394,6 @@ class FileDisk extends FileBase {
...
@@ -398,7 +394,6 @@ class FileDisk extends FileBase {
public
FileChannel
truncate
(
long
newLength
)
throws
IOException
{
public
FileChannel
truncate
(
long
newLength
)
throws
IOException
{
if
(
newLength
<
file
.
length
())
{
if
(
newLength
<
file
.
length
())
{
// some implementations actually only support truncate
file
.
setLength
(
newLength
);
file
.
setLength
(
newLength
);
}
}
return
this
;
return
this
;
...
...
h2/src/main/org/h2/store/fs/FilePathMem.java
浏览文件 @
ac65d7c1
...
@@ -136,14 +136,10 @@ public class FilePathMem extends FilePath {
...
@@ -136,14 +136,10 @@ public class FilePathMem extends FilePath {
// TODO directories are not really supported
// TODO directories are not really supported
}
}
public
OutputStream
newOutputStream
(
boolean
append
)
{
public
OutputStream
newOutputStream
(
boolean
append
)
throws
IOException
{
try
{
FileMemData
obj
=
getMemoryFile
();
FileMemData
obj
=
getMemoryFile
();
FileMem
m
=
new
FileMem
(
obj
,
false
);
FileMem
m
=
new
FileMem
(
obj
,
false
);
return
new
FileChannelOutputStream
(
m
,
append
);
return
new
FileChannelOutputStream
(
m
,
append
);
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
name
);
}
}
}
public
InputStream
newInputStream
()
{
public
InputStream
newInputStream
()
{
...
...
h2/src/main/org/h2/store/fs/FilePathRec.java
浏览文件 @
ac65d7c1
...
@@ -59,7 +59,7 @@ public class FilePathRec extends FilePathWrapper {
...
@@ -59,7 +59,7 @@ public class FilePathRec extends FilePathWrapper {
return
new
FileRec
(
this
,
super
.
open
(
mode
),
name
);
return
new
FileRec
(
this
,
super
.
open
(
mode
),
name
);
}
}
public
OutputStream
newOutputStream
(
boolean
append
)
{
public
OutputStream
newOutputStream
(
boolean
append
)
throws
IOException
{
log
(
Recorder
.
OPEN_OUTPUT_STREAM
,
name
);
log
(
Recorder
.
OPEN_OUTPUT_STREAM
,
name
);
return
super
.
newOutputStream
(
append
);
return
super
.
newOutputStream
(
append
);
}
}
...
...
h2/src/main/org/h2/store/fs/FilePathSplit.java
浏览文件 @
ac65d7c1
...
@@ -166,12 +166,8 @@ public class FilePathSplit extends FilePathWrapper {
...
@@ -166,12 +166,8 @@ public class FilePathSplit extends FilePathWrapper {
throw
new
IOException
(
message
);
throw
new
IOException
(
message
);
}
}
public
OutputStream
newOutputStream
(
boolean
append
)
{
public
OutputStream
newOutputStream
(
boolean
append
)
throws
IOException
{
try
{
return
new
FileChannelOutputStream
(
open
(
"rw"
),
append
);
return
new
FileChannelOutputStream
(
open
(
"rw"
),
append
);
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
name
);
}
}
}
public
void
moveTo
(
FilePath
path
)
{
public
void
moveTo
(
FilePath
path
)
{
...
...
h2/src/main/org/h2/store/fs/FilePathWrapper.java
浏览文件 @
ac65d7c1
...
@@ -124,7 +124,7 @@ public abstract class FilePathWrapper extends FilePath {
...
@@ -124,7 +124,7 @@ public abstract class FilePathWrapper extends FilePath {
return
base
.
newInputStream
();
return
base
.
newInputStream
();
}
}
public
OutputStream
newOutputStream
(
boolean
append
)
{
public
OutputStream
newOutputStream
(
boolean
append
)
throws
IOException
{
return
base
.
newOutputStream
(
append
);
return
base
.
newOutputStream
(
append
);
}
}
...
...
h2/src/main/org/h2/store/fs/FilePathZip.java
浏览文件 @
ac65d7c1
...
@@ -168,8 +168,8 @@ public class FilePathZip extends FilePath {
...
@@ -168,8 +168,8 @@ public class FilePathZip extends FilePath {
return
new
FileZip
(
file
,
entry
);
return
new
FileZip
(
file
,
entry
);
}
}
public
OutputStream
newOutputStream
(
boolean
append
)
{
public
OutputStream
newOutputStream
(
boolean
append
)
throws
IOException
{
throw
DbException
.
getUnsupported
Exception
(
"write"
);
throw
new
IO
Exception
(
"write"
);
}
}
public
void
moveTo
(
FilePath
newName
)
{
public
void
moveTo
(
FilePath
newName
)
{
...
...
h2/src/main/org/h2/store/fs/FileUtils.java
浏览文件 @
ac65d7c1
...
@@ -219,7 +219,7 @@ public class FileUtils {
...
@@ -219,7 +219,7 @@ public class FileUtils {
* truncated first
* truncated first
* @return the output stream
* @return the output stream
*/
*/
public
static
OutputStream
newOutputStream
(
String
fileName
,
boolean
append
)
{
public
static
OutputStream
newOutputStream
(
String
fileName
,
boolean
append
)
throws
IOException
{
return
FilePath
.
get
(
fileName
).
newOutputStream
(
append
);
return
FilePath
.
get
(
fileName
).
newOutputStream
(
append
);
}
}
...
...
h2/src/test/org/h2/test/unit/TestFileSystem.java
浏览文件 @
ac65d7c1
...
@@ -6,7 +6,6 @@
...
@@ -6,7 +6,6 @@
*/
*/
package
org
.
h2
.
test
.
unit
;
package
org
.
h2
.
test
.
unit
;
import
java.io.EOFException
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
...
@@ -25,6 +24,7 @@ import java.util.List;
...
@@ -25,6 +24,7 @@ import java.util.List;
import
java.util.Random
;
import
java.util.Random
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.store.fs.FilePath
;
import
org.h2.store.fs.FilePath
;
import
org.h2.store.fs.FilePathCrypt
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.test.utils.AssertThrows
;
import
org.h2.test.utils.AssertThrows
;
...
@@ -58,8 +58,8 @@ public class TestFileSystem extends TestBase {
...
@@ -58,8 +58,8 @@ public class TestFileSystem extends TestBase {
testMemFsDir
();
testMemFsDir
();
testClasspath
();
testClasspath
();
FilePathDebug
.
register
().
setTrace
(
true
);
FilePathDebug
.
register
().
setTrace
(
true
);
// testFileSystem("crypt:007:" + getBaseDir() + "/fs"
);
FilePathCrypt
.
register
(
);
testFileSystem
(
"crypt:0007:"
+
getBaseDir
()
+
"/fs"
);
testSimpleExpandTruncateSize
();
testSimpleExpandTruncateSize
();
testSplitDatabaseInZip
();
testSplitDatabaseInZip
();
testDatabaseInMemFileSys
();
testDatabaseInMemFileSys
();
...
@@ -72,7 +72,6 @@ public class TestFileSystem extends TestBase {
...
@@ -72,7 +72,6 @@ public class TestFileSystem extends TestBase {
testFileSystem
(
"memLZF:"
);
testFileSystem
(
"memLZF:"
);
testUserHome
();
testUserHome
();
try
{
try
{
// testFileSystem("crypt:007:" + getBaseDir() + "/fs");
testFileSystem
(
"nio:"
+
getBaseDir
()
+
"/fs"
);
testFileSystem
(
"nio:"
+
getBaseDir
()
+
"/fs"
);
testFileSystem
(
"nioMapped:"
+
getBaseDir
()
+
"/fs"
);
testFileSystem
(
"nioMapped:"
+
getBaseDir
()
+
"/fs"
);
if
(!
config
.
splitFileSystem
)
{
if
(!
config
.
splitFileSystem
)
{
...
@@ -230,7 +229,7 @@ public class TestFileSystem extends TestBase {
...
@@ -230,7 +229,7 @@ public class TestFileSystem extends TestBase {
}
}
private
void
testReadOnly
(
final
String
f
)
throws
IOException
{
private
void
testReadOnly
(
final
String
f
)
throws
IOException
{
new
AssertThrows
(
DbException
.
class
)
{
public
void
test
()
{
new
AssertThrows
(
IOException
.
class
)
{
public
void
test
()
throws
IOException
{
FileUtils
.
newOutputStream
(
f
,
false
);
FileUtils
.
newOutputStream
(
f
,
false
);
}};
}};
new
AssertThrows
(
DbException
.
class
)
{
public
void
test
()
{
new
AssertThrows
(
DbException
.
class
)
{
public
void
test
()
{
...
@@ -500,6 +499,7 @@ public class TestFileSystem extends TestBase {
...
@@ -500,6 +499,7 @@ public class TestFileSystem extends TestBase {
}
}
case
2
:
{
case
2
:
{
trace
(
"truncate "
+
pos
);
trace
(
"truncate "
+
pos
);
buff
.
append
(
"truncate "
+
pos
+
"\n"
);
f
.
truncate
(
pos
);
f
.
truncate
(
pos
);
if
(
pos
<
ra
.
length
())
{
if
(
pos
<
ra
.
length
())
{
// truncate is supposed to have no effect if the
// truncate is supposed to have no effect if the
...
@@ -507,7 +507,6 @@ public class TestFileSystem extends TestBase {
...
@@ -507,7 +507,6 @@ public class TestFileSystem extends TestBase {
ra
.
setLength
(
pos
);
ra
.
setLength
(
pos
);
}
}
assertEquals
(
ra
.
getFilePointer
(),
f
.
position
());
assertEquals
(
ra
.
getFilePointer
(),
f
.
position
());
buff
.
append
(
"truncate "
+
pos
+
"\n"
);
break
;
break
;
}
}
case
3
:
{
case
3
:
{
...
@@ -516,13 +515,9 @@ public class TestFileSystem extends TestBase {
...
@@ -516,13 +515,9 @@ public class TestFileSystem extends TestBase {
byte
[]
b1
=
new
byte
[
len
];
byte
[]
b1
=
new
byte
[
len
];
byte
[]
b2
=
new
byte
[
len
];
byte
[]
b2
=
new
byte
[
len
];
trace
(
"readFully "
+
len
);
trace
(
"readFully "
+
len
);
buff
.
append
(
"readFully "
+
len
+
"\n"
);
ra
.
readFully
(
b1
,
0
,
len
);
ra
.
readFully
(
b1
,
0
,
len
);
try
{
FileUtils
.
readFully
(
f
,
ByteBuffer
.
wrap
(
b2
,
0
,
len
));
FileUtils
.
readFully
(
f
,
ByteBuffer
.
wrap
(
b2
,
0
,
len
));
}
catch
(
EOFException
e
)
{
e
.
printStackTrace
();
}
buff
.
append
(
"readFully "
+
len
+
"\n"
);
assertEquals
(
b1
,
b2
);
assertEquals
(
b1
,
b2
);
break
;
break
;
}
}
...
...
h2/src/test/org/h2/test/utils/FilePathDebug.java
浏览文件 @
ac65d7c1
...
@@ -132,7 +132,7 @@ public class FilePathDebug extends FilePathWrapper {
...
@@ -132,7 +132,7 @@ public class FilePathDebug extends FilePathWrapper {
public
InputStream
newInputStream
()
throws
IOException
{
public
InputStream
newInputStream
()
throws
IOException
{
trace
(
name
,
"newInputStream"
);
trace
(
name
,
"newInputStream"
);
InputStream
in
=
super
.
newInputStream
();
InputStream
in
=
super
.
newInputStream
();
if
(!
trace
)
{
if
(!
isTrace
()
)
{
return
in
;
return
in
;
}
}
final
String
fileName
=
name
;
final
String
fileName
=
name
;
...
@@ -159,7 +159,7 @@ public class FilePathDebug extends FilePathWrapper {
...
@@ -159,7 +159,7 @@ public class FilePathDebug extends FilePathWrapper {
return
new
FileDebug
(
this
,
super
.
open
(
mode
),
name
);
return
new
FileDebug
(
this
,
super
.
open
(
mode
),
name
);
}
}
public
OutputStream
newOutputStream
(
boolean
append
)
{
public
OutputStream
newOutputStream
(
boolean
append
)
throws
IOException
{
trace
(
name
,
"newOutputStream"
,
append
);
trace
(
name
,
"newOutputStream"
,
append
);
return
super
.
newOutputStream
(
append
);
return
super
.
newOutputStream
(
append
);
}
}
...
@@ -183,7 +183,7 @@ public class FilePathDebug extends FilePathWrapper {
...
@@ -183,7 +183,7 @@ public class FilePathDebug extends FilePathWrapper {
* @param params parameters if any
* @param params parameters if any
*/
*/
void
trace
(
String
fileName
,
String
method
,
Object
...
params
)
{
void
trace
(
String
fileName
,
String
method
,
Object
...
params
)
{
if
(
trace
)
{
if
(
isTrace
()
)
{
StringBuilder
buff
=
new
StringBuilder
(
" "
);
StringBuilder
buff
=
new
StringBuilder
(
" "
);
buff
.
append
(
unwrap
(
fileName
)).
append
(
' '
).
append
(
method
);
buff
.
append
(
unwrap
(
fileName
)).
append
(
' '
).
append
(
method
);
for
(
Object
s
:
params
)
{
for
(
Object
s
:
params
)
{
...
@@ -202,11 +202,11 @@ public class FilePathDebug extends FilePathWrapper {
...
@@ -202,11 +202,11 @@ public class FilePathDebug extends FilePathWrapper {
}
}
public
boolean
isTrace
()
{
public
boolean
isTrace
()
{
return
trace
;
return
INSTANCE
.
trace
;
}
}
public
void
setTrace
(
boolean
trace
)
{
public
void
setTrace
(
boolean
trace
)
{
this
.
trace
=
trace
;
INSTANCE
.
trace
=
trace
;
}
}
public
String
getScheme
()
{
public
String
getScheme
()
{
...
@@ -227,7 +227,7 @@ class FileDebug extends FileBase {
...
@@ -227,7 +227,7 @@ class FileDebug extends FileBase {
FileDebug
(
FilePathDebug
debug
,
FileChannel
channel
,
String
name
)
{
FileDebug
(
FilePathDebug
debug
,
FileChannel
channel
,
String
name
)
{
this
.
debug
=
debug
;
this
.
debug
=
debug
;
this
.
channel
=
channel
;
this
.
channel
=
channel
;
this
.
name
=
debug
.
getScheme
()
+
":"
+
name
;
this
.
name
=
name
;
}
}
public
void
implCloseChannel
()
throws
IOException
{
public
void
implCloseChannel
()
throws
IOException
{
...
@@ -296,4 +296,8 @@ class FileDebug extends FileBase {
...
@@ -296,4 +296,8 @@ class FileDebug extends FileBase {
return
channel
.
tryLock
(
position
,
size
,
shared
);
return
channel
.
tryLock
(
position
,
size
,
shared
);
}
}
public
String
toString
()
{
return
name
;
}
}
}
h2/src/test/org/h2/test/utils/FilePathUnstable.java
浏览文件 @
ac65d7c1
...
@@ -122,7 +122,7 @@ public class FilePathUnstable extends FilePathWrapper {
...
@@ -122,7 +122,7 @@ public class FilePathUnstable extends FilePathWrapper {
return
new
FileUnstable
(
this
,
super
.
open
(
mode
));
return
new
FileUnstable
(
this
,
super
.
open
(
mode
));
}
}
public
OutputStream
newOutputStream
(
boolean
append
)
{
public
OutputStream
newOutputStream
(
boolean
append
)
throws
IOException
{
return
super
.
newOutputStream
(
append
);
return
super
.
newOutputStream
(
append
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论