Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
ba0269de
提交
ba0269de
authored
3月 21, 2011
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Slightly simplified FileSystem copy
上级
d7de0330
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
31 行增加
和
90 行删除
+31
-90
FileSystem.java
h2/src/main/org/h2/store/fs/FileSystem.java
+0
-8
FileSystemDisk.java
h2/src/main/org/h2/store/fs/FileSystemDisk.java
+0
-17
FileSystemMemory.java
h2/src/main/org/h2/store/fs/FileSystemMemory.java
+0
-11
FileSystemSplit.java
h2/src/main/org/h2/store/fs/FileSystemSplit.java
+0
-15
FileSystemWrapper.java
h2/src/main/org/h2/store/fs/FileSystemWrapper.java
+0
-4
FileSystemZip.java
h2/src/main/org/h2/store/fs/FileSystemZip.java
+0
-4
IOUtils.java
h2/src/main/org/h2/util/IOUtils.java
+6
-4
FileSystemDatabase.java
h2/src/test/org/h2/test/unit/FileSystemDatabase.java
+0
-11
TestFileSystem.java
h2/src/test/org/h2/test/unit/TestFileSystem.java
+1
-1
TestReopen.java
h2/src/test/org/h2/test/unit/TestReopen.java
+2
-3
DebugFileSystem.java
h2/src/test/org/h2/test/utils/DebugFileSystem.java
+22
-7
RecordingFileSystem.java
h2/src/test/org/h2/test/utils/RecordingFileSystem.java
+0
-5
没有找到文件。
h2/src/main/org/h2/store/fs/FileSystem.java
浏览文件 @
ba0269de
...
@@ -214,14 +214,6 @@ public abstract class FileSystem {
...
@@ -214,14 +214,6 @@ public abstract class FileSystem {
*/
*/
public
abstract
boolean
canWrite
(
String
fileName
);
public
abstract
boolean
canWrite
(
String
fileName
);
/**
* Copy a file from one directory to another, or to another file.
*
* @param source the name of the original file
* @param target the file name of the copy
*/
public
abstract
void
copy
(
String
source
,
String
target
);
/**
/**
* Create all required directories that are required for this file.
* Create all required directories that are required for this file.
*
*
...
...
h2/src/main/org/h2/store/fs/FileSystemDisk.java
浏览文件 @
ba0269de
...
@@ -309,23 +309,6 @@ public class FileSystemDisk extends FileSystem {
...
@@ -309,23 +309,6 @@ public class FileSystemDisk extends FileSystem {
}
}
}
}
public
void
copy
(
String
source
,
String
target
)
{
source
=
translateFileName
(
source
);
target
=
translateFileName
(
target
);
OutputStream
out
=
null
;
InputStream
in
=
null
;
try
{
in
=
IOUtils
.
openFileInputStream
(
source
);
out
=
IOUtils
.
openFileOutputStream
(
target
,
false
);
IOUtils
.
copy
(
in
,
out
);
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
"original: "
+
source
+
" copy: "
+
target
);
}
finally
{
IOUtils
.
closeSilently
(
in
);
IOUtils
.
closeSilently
(
out
);
}
}
public
void
createDirs
(
String
fileName
)
{
public
void
createDirs
(
String
fileName
)
{
fileName
=
translateFileName
(
fileName
);
fileName
=
translateFileName
(
fileName
);
File
f
=
new
File
(
fileName
);
File
f
=
new
File
(
fileName
);
...
...
h2/src/main/org/h2/store/fs/FileSystemMemory.java
浏览文件 @
ba0269de
...
@@ -13,7 +13,6 @@ import java.util.ArrayList;
...
@@ -13,7 +13,6 @@ import java.util.ArrayList;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.TreeMap
;
import
java.util.TreeMap
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.util.IOUtils
;
import
org.h2.util.New
;
import
org.h2.util.New
;
/**
/**
...
@@ -163,16 +162,6 @@ public class FileSystemMemory extends FileSystem {
...
@@ -163,16 +162,6 @@ public class FileSystemMemory extends FileSystem {
return
true
;
return
true
;
}
}
public
void
copy
(
String
source
,
String
target
)
{
try
{
OutputStream
out
=
openFileOutputStream
(
target
,
false
);
InputStream
in
=
openFileInputStream
(
source
);
IOUtils
.
copyAndClose
(
in
,
out
);
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
"Can not copy "
+
source
+
" to "
+
target
);
}
}
public
void
createDirs
(
String
fileName
)
{
public
void
createDirs
(
String
fileName
)
{
// TODO directories are not really supported
// TODO directories are not really supported
}
}
...
...
h2/src/main/org/h2/store/fs/FileSystemSplit.java
浏览文件 @
ba0269de
...
@@ -49,21 +49,6 @@ public class FileSystemSplit extends FileSystemWrapper {
...
@@ -49,21 +49,6 @@ public class FileSystemSplit extends FileSystemWrapper {
return
result
;
return
result
;
}
}
public
void
copy
(
String
source
,
String
target
)
{
source
=
unwrap
(
source
);
target
=
unwrap
(
target
);
getInstance
(
source
).
copy
(
source
,
target
);
for
(
int
i
=
1
;;
i
++)
{
String
o
=
getFileName
(
source
,
i
);
if
(
getInstance
(
o
).
exists
(
o
))
{
String
c
=
getFileName
(
target
,
i
);
getInstance
(
o
).
copy
(
o
,
c
);
}
else
{
break
;
}
}
}
public
void
delete
(
String
fileName
)
{
public
void
delete
(
String
fileName
)
{
fileName
=
unwrap
(
fileName
);
fileName
=
unwrap
(
fileName
);
for
(
int
i
=
0
;;
i
++)
{
for
(
int
i
=
0
;;
i
++)
{
...
...
h2/src/main/org/h2/store/fs/FileSystemWrapper.java
浏览文件 @
ba0269de
...
@@ -33,10 +33,6 @@ public abstract class FileSystemWrapper extends FileSystem {
...
@@ -33,10 +33,6 @@ public abstract class FileSystemWrapper extends FileSystem {
return
IOUtils
.
setReadOnly
(
unwrap
(
fileName
));
return
IOUtils
.
setReadOnly
(
unwrap
(
fileName
));
}
}
public
void
copy
(
String
source
,
String
target
)
{
IOUtils
.
copy
(
unwrap
(
source
),
unwrap
(
target
));
}
public
void
createDirs
(
String
fileName
)
{
public
void
createDirs
(
String
fileName
)
{
IOUtils
.
createDirs
(
unwrap
(
fileName
));
IOUtils
.
createDirs
(
unwrap
(
fileName
));
}
}
...
...
h2/src/main/org/h2/store/fs/FileSystemZip.java
浏览文件 @
ba0269de
...
@@ -33,10 +33,6 @@ public class FileSystemZip extends FileSystem {
...
@@ -33,10 +33,6 @@ public class FileSystemZip extends FileSystem {
return
false
;
return
false
;
}
}
public
void
copy
(
String
original
,
String
copy
)
{
throw
DbException
.
getUnsupportedException
(
"write"
);
}
public
void
createDirs
(
String
fileName
)
{
public
void
createDirs
(
String
fileName
)
{
// ignore
// ignore
}
}
...
...
h2/src/main/org/h2/util/IOUtils.java
浏览文件 @
ba0269de
...
@@ -433,7 +433,7 @@ public class IOUtils {
...
@@ -433,7 +433,7 @@ public class IOUtils {
* @param s the string
* @param s the string
* @return the input stream
* @return the input stream
*/
*/
public
static
InputStream
getInputStream
(
String
s
)
{
public
static
InputStream
getInputStream
FromString
(
String
s
)
{
if
(
s
==
null
)
{
if
(
s
==
null
)
{
return
null
;
return
null
;
}
}
...
@@ -447,7 +447,7 @@ public class IOUtils {
...
@@ -447,7 +447,7 @@ public class IOUtils {
* @param s the string or null
* @param s the string or null
* @return the reader
* @return the reader
*/
*/
public
static
Reader
getReader
(
String
s
)
{
public
static
Reader
getReader
FromString
(
String
s
)
{
return
s
==
null
?
null
:
new
StringReader
(
s
);
return
s
==
null
?
null
:
new
StringReader
(
s
);
}
}
...
@@ -556,8 +556,10 @@ public class IOUtils {
...
@@ -556,8 +556,10 @@ public class IOUtils {
* @param original the original file name
* @param original the original file name
* @param copy the file name of the copy
* @param copy the file name of the copy
*/
*/
public
static
void
copy
(
String
original
,
String
copy
)
{
public
static
void
copy
(
String
original
,
String
copy
)
throws
IOException
{
getFileSystem
(
original
).
copy
(
original
,
copy
);
InputStream
in
=
openFileInputStream
(
original
);
OutputStream
out
=
openFileOutputStream
(
copy
,
false
);
copyAndClose
(
in
,
out
);
}
}
/**
/**
...
...
h2/src/test/org/h2/test/unit/FileSystemDatabase.java
浏览文件 @
ba0269de
...
@@ -175,17 +175,6 @@ public class FileSystemDatabase extends FileSystem {
...
@@ -175,17 +175,6 @@ public class FileSystemDatabase extends FileSystem {
return
true
;
return
true
;
}
}
public
void
copy
(
String
source
,
String
target
)
{
try
{
OutputStream
out
=
openFileOutputStream
(
target
,
false
);
InputStream
in
=
openFileInputStream
(
source
);
IOUtils
.
copyAndClose
(
in
,
out
);
}
catch
(
IOException
e
)
{
rollback
();
throw
DbException
.
convertIOException
(
e
,
"Can not copy "
+
source
+
" to "
+
target
);
}
}
public
void
createDirs
(
String
fileName
)
{
public
void
createDirs
(
String
fileName
)
{
fileName
=
unwrap
(
fileName
);
fileName
=
unwrap
(
fileName
);
try
{
try
{
...
...
h2/src/test/org/h2/test/unit/TestFileSystem.java
浏览文件 @
ba0269de
...
@@ -242,7 +242,7 @@ public class TestFileSystem extends TestBase {
...
@@ -242,7 +242,7 @@ public class TestFileSystem extends TestBase {
String
[]
list
=
fs
.
listFiles
(
fsBase
);
String
[]
list
=
fs
.
listFiles
(
fsBase
);
assertEquals
(
1
,
list
.
length
);
assertEquals
(
1
,
list
.
length
);
assertTrue
(
list
[
0
].
endsWith
(
"test"
));
assertTrue
(
list
[
0
].
endsWith
(
"test"
));
f
s
.
copy
(
fsBase
+
"/test"
,
fsBase
+
"/test3"
);
IOUtil
s
.
copy
(
fsBase
+
"/test"
,
fsBase
+
"/test3"
);
fs
.
rename
(
fsBase
+
"/test3"
,
fsBase
+
"/test2"
);
fs
.
rename
(
fsBase
+
"/test3"
,
fsBase
+
"/test2"
);
assertTrue
(!
fs
.
exists
(
fsBase
+
"/test3"
));
assertTrue
(!
fs
.
exists
(
fsBase
+
"/test3"
));
assertTrue
(
fs
.
exists
(
fsBase
+
"/test2"
));
assertTrue
(
fs
.
exists
(
fsBase
+
"/test2"
));
...
...
h2/src/test/org/h2/test/unit/TestReopen.java
浏览文件 @
ba0269de
...
@@ -15,7 +15,6 @@ import org.h2.engine.Constants;
...
@@ -15,7 +15,6 @@ import org.h2.engine.Constants;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.test.utils.Recorder
;
import
org.h2.test.utils.Recorder
;
import
org.h2.test.utils.RecordingFileSystem
;
import
org.h2.test.utils.RecordingFileSystem
;
...
@@ -98,8 +97,8 @@ public class TestReopen extends TestBase implements Recorder {
...
@@ -98,8 +97,8 @@ public class TestReopen extends TestBase implements Recorder {
// System.out.println(fileName + " " + IOUtils.length(fileName));
// System.out.println(fileName + " " + IOUtils.length(fileName));
return
;
return
;
}
}
FileSystem
.
getInstance
(
fileName
).
copy
(
fileName
,
testDatabase
+
Constants
.
SUFFIX_PAGE_FILE
);
try
{
try
{
IOUtils
.
copy
(
fileName
,
testDatabase
+
Constants
.
SUFFIX_PAGE_FILE
);
verifyCount
++;
verifyCount
++;
// avoid using the Engine class to avoid deadlocks
// avoid using the Engine class to avoid deadlocks
Properties
p
=
new
Properties
();
Properties
p
=
new
Properties
();
...
@@ -143,8 +142,8 @@ public class TestReopen extends TestBase implements Recorder {
...
@@ -143,8 +142,8 @@ public class TestReopen extends TestBase implements Recorder {
// ignore
// ignore
}
}
testDatabase
+=
"X"
;
testDatabase
+=
"X"
;
FileSystem
.
getInstance
(
fileName
).
copy
(
fileName
,
testDatabase
+
Constants
.
SUFFIX_PAGE_FILE
);
try
{
try
{
IOUtils
.
copy
(
fileName
,
testDatabase
+
Constants
.
SUFFIX_PAGE_FILE
);
// avoid using the Engine class to avoid deadlocks
// avoid using the Engine class to avoid deadlocks
Properties
p
=
new
Properties
();
Properties
p
=
new
Properties
();
ConnectionInfo
ci
=
new
ConnectionInfo
(
"jdbc:h2:"
+
testDatabase
+
";FILE_LOCK=NO"
,
p
);
ConnectionInfo
ci
=
new
ConnectionInfo
(
"jdbc:h2:"
+
testDatabase
+
";FILE_LOCK=NO"
,
p
);
...
...
h2/src/test/org/h2/test/utils/DebugFileSystem.java
浏览文件 @
ba0269de
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
*/
*/
package
org
.
h2
.
test
.
utils
;
package
org
.
h2
.
test
.
utils
;
import
java.io.FilterInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
...
@@ -64,11 +65,6 @@ public class DebugFileSystem extends FileSystemWrapper {
...
@@ -64,11 +65,6 @@ public class DebugFileSystem extends FileSystemWrapper {
return
super
.
canWrite
(
fileName
);
return
super
.
canWrite
(
fileName
);
}
}
public
void
copy
(
String
source
,
String
target
)
{
trace
(
source
,
"copy"
,
unwrap
(
target
));
super
.
copy
(
source
,
target
);
}
public
void
createDirs
(
String
fileName
)
{
public
void
createDirs
(
String
fileName
)
{
trace
(
fileName
,
"createDirs"
);
trace
(
fileName
,
"createDirs"
);
super
.
createDirs
(
fileName
);
super
.
createDirs
(
fileName
);
...
@@ -155,9 +151,28 @@ public class DebugFileSystem extends FileSystemWrapper {
...
@@ -155,9 +151,28 @@ public class DebugFileSystem extends FileSystemWrapper {
return
super
.
getCanonicalPath
(
fileName
);
return
super
.
getCanonicalPath
(
fileName
);
}
}
public
InputStream
openFileInputStream
(
String
fileName
)
throws
IOException
{
public
InputStream
openFileInputStream
(
final
String
fileName
)
throws
IOException
{
trace
(
fileName
,
"openFileInputStream"
);
trace
(
fileName
,
"openFileInputStream"
);
return
super
.
openFileInputStream
(
fileName
);
InputStream
in
=
super
.
openFileInputStream
(
fileName
);
if
(!
trace
)
{
return
in
;
}
return
new
FilterInputStream
(
in
)
{
public
int
read
(
byte
[]
b
)
throws
IOException
{
trace
(
fileName
,
"in.read(b)"
);
return
super
.
read
(
b
);
}
public
int
read
(
byte
[]
b
,
int
off
,
int
len
)
throws
IOException
{
trace
(
fileName
,
"in.read(b, "
+
off
+
", "
+
len
+
")"
);
return
super
.
read
(
b
,
off
,
len
);
}
public
long
skip
(
long
n
)
throws
IOException
{
trace
(
fileName
,
"in.skip("
+
n
+
")"
);
return
super
.
skip
(
n
);
}
};
}
}
public
FileObject
openFileObject
(
String
fileName
,
String
mode
)
throws
IOException
{
public
FileObject
openFileObject
(
String
fileName
,
String
mode
)
throws
IOException
{
...
...
h2/src/test/org/h2/test/utils/RecordingFileSystem.java
浏览文件 @
ba0269de
...
@@ -44,11 +44,6 @@ public class RecordingFileSystem extends FileSystemWrapper {
...
@@ -44,11 +44,6 @@ public class RecordingFileSystem extends FileSystemWrapper {
RecordingFileSystem
.
recorder
=
recorder
;
RecordingFileSystem
.
recorder
=
recorder
;
}
}
public
void
copy
(
String
source
,
String
target
)
{
log
(
Recorder
.
COPY
,
unwrap
(
source
)
+
":"
+
unwrap
(
target
));
super
.
copy
(
source
,
target
);
}
public
void
createDirs
(
String
fileName
)
{
public
void
createDirs
(
String
fileName
)
{
log
(
Recorder
.
CREATE_DIRS
,
unwrap
(
fileName
));
log
(
Recorder
.
CREATE_DIRS
,
unwrap
(
fileName
));
super
.
createDirs
(
fileName
);
super
.
createDirs
(
fileName
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论