Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
abc9cec3
提交
abc9cec3
authored
9月 16, 2011
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improved compatibility with the Java 7 FileSystem abstraction.
上级
5c412dbc
隐藏空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
38 行增加
和
111 行删除
+38
-111
advanced.html
h2/src/docsrc/html/advanced.html
+2
-2
Database.java
h2/src/main/org/h2/engine/Database.java
+1
-1
FileLister.java
h2/src/main/org/h2/store/FileLister.java
+3
-3
FilePath.java
h2/src/main/org/h2/store/fs/FilePath.java
+6
-10
FilePathDisk.java
h2/src/main/org/h2/store/fs/FilePathDisk.java
+0
-20
FilePathMem.java
h2/src/main/org/h2/store/fs/FilePathMem.java
+5
-13
FilePathNio.java
h2/src/main/org/h2/store/fs/FilePathNio.java
+2
-15
FilePathNioMapped.java
h2/src/main/org/h2/store/fs/FilePathNioMapped.java
+1
-6
FilePathWrapper.java
h2/src/main/org/h2/store/fs/FilePathWrapper.java
+12
-4
FilePathZip.java
h2/src/main/org/h2/store/fs/FilePathZip.java
+0
-12
FileUtils.java
h2/src/main/org/h2/store/fs/FileUtils.java
+2
-13
FilePathDebug.java
h2/src/test/org/h2/test/utils/FilePathDebug.java
+0
-5
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+1
-1
FilePathCrypt.java
h2/src/tools/org/h2/dev/fs/FilePathCrypt.java
+3
-0
FilePathZip2.java
h2/src/tools/org/h2/dev/fs/FilePathZip2.java
+0
-4
FtpData.java
h2/src/tools/org/h2/dev/ftp/server/FtpData.java
+0
-2
没有找到文件。
h2/src/docsrc/html/advanced.html
浏览文件 @
abc9cec3
...
...
@@ -1483,8 +1483,8 @@ As an example, to use the the <code>nio</code> file system, use the following da
<code>
jdbc:h2:nio:~/test
</code>
.
</p>
<p>
To register a new file system, extend the classes
<code>
org.h2.store.fs.File
System
, FileObject
</code>
,
and call the method
<code>
File
System
.register
</code>
before using it.
To register a new file system, extend the classes
<code>
org.h2.store.fs.File
Path
, FileObject
</code>
,
and call the method
<code>
File
Path
.register
</code>
before using it.
</p>
<p>
For input streams (but not for random access files), URLs may be used in addition to the registered file systems.
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
abc9cec3
...
...
@@ -1479,7 +1479,7 @@ public class Database implements DataHandler {
String
path
=
FileUtils
.
getParent
(
databaseName
);
String
[]
list
=
FileUtils
.
listFiles
(
path
);
for
(
String
name
:
list
)
{
if
(
name
.
endsWith
(
Constants
.
SUFFIX_TEMP_FILE
)
&&
FileUtils
.
fileStartsWith
(
name
,
databaseName
))
{
if
(
name
.
endsWith
(
Constants
.
SUFFIX_TEMP_FILE
)
&&
name
.
startsWith
(
databaseName
))
{
// can't always delete the files, they may still be open
FileUtils
.
tryDelete
(
name
);
}
...
...
h2/src/main/org/h2/store/FileLister.java
浏览文件 @
abc9cec3
...
...
@@ -73,13 +73,13 @@ public class FileLister {
*/
public
static
ArrayList
<
String
>
getDatabaseFiles
(
String
dir
,
String
db
,
boolean
all
)
{
ArrayList
<
String
>
files
=
New
.
arrayList
();
String
start
=
db
==
null
?
null
:
FileUtils
.
getCanonicalPath
(
dir
+
"/"
+
db
);
String
start
=
db
==
null
?
null
:
FileUtils
.
getCanonicalPath
(
dir
+
"/"
+
db
+
"."
);
String
[]
list
=
FileUtils
.
listFiles
(
dir
);
for
(
int
i
=
0
;
list
!=
null
&&
i
<
list
.
length
;
i
++)
{
String
f
=
list
[
i
];
boolean
ok
=
false
;
if
(
f
.
endsWith
(
Constants
.
SUFFIX_LOBS_DIRECTORY
))
{
if
(
start
==
null
||
FileUtils
.
fileStartsWith
(
f
,
start
+
"."
))
{
if
(
start
==
null
||
f
.
startsWith
(
start
))
{
files
.
addAll
(
getDatabaseFiles
(
f
,
null
,
all
));
ok
=
true
;
}
...
...
@@ -97,7 +97,7 @@ public class FileLister {
}
}
if
(
ok
)
{
if
(
db
==
null
||
FileUtils
.
fileStartsWith
(
f
,
start
+
"."
))
{
if
(
db
==
null
||
f
.
startsWith
(
start
))
{
String
fileName
=
f
;
files
.
add
(
fileName
);
}
...
...
h2/src/main/org/h2/store/fs/FilePath.java
浏览文件 @
abc9cec3
...
...
@@ -34,6 +34,10 @@ public abstract class FilePath {
private
static
String
tempRandom
;
private
static
long
tempSequence
;
/**
* The complete path (which may be absolute or relative, depending on the
* file system).
*/
protected
String
name
;
/**
...
...
@@ -199,14 +203,6 @@ public abstract class FilePath {
return
idx
<
0
?
name
:
name
.
substring
(
idx
+
1
);
}
/**
* Check if a file starts with a given prefix.
*
* @param prefix the prefix
* @return true if it starts with the prefix
*/
public
abstract
boolean
fileStartsWith
(
String
prefix
);
/**
* Create an output stream to write into the file.
*
...
...
@@ -299,8 +295,8 @@ public abstract class FilePath {
* return an object even if the scheme doesn't match in case of the the
* default file provider.
*
* @param path
* @return the file path
* @param path
the path
* @return the file path
object
*/
public
abstract
FilePath
getPath
(
String
path
);
...
...
h2/src/main/org/h2/store/fs/FilePathDisk.java
浏览文件 @
abc9cec3
...
...
@@ -22,7 +22,6 @@ import org.h2.constant.SysProperties;
import
org.h2.message.DbException
;
import
org.h2.util.IOUtils
;
import
org.h2.util.New
;
import
org.h2.util.StringUtils
;
import
org.h2.util.Utils
;
/**
...
...
@@ -31,7 +30,6 @@ import org.h2.util.Utils;
*/
public
class
FilePathDisk
extends
FilePath
{
private
static
final
boolean
IS_FILE_SYSTEM_CASE_INSENSITIVE
=
File
.
separatorChar
==
'\\'
;
private
static
final
String
CLASSPATH_PREFIX
=
"classpath:"
;
public
FilePathDisk
getPath
(
String
path
)
{
...
...
@@ -246,16 +244,6 @@ public class FilePathDisk extends FilePath {
}
}
public
boolean
fileStartsWith
(
String
prefix
)
{
prefix
=
translateFileName
(
prefix
);
String
fileName
=
name
;
if
(
IS_FILE_SYSTEM_CASE_INSENSITIVE
)
{
fileName
=
StringUtils
.
toUpperEnglish
(
fileName
);
prefix
=
StringUtils
.
toUpperEnglish
(
prefix
);
}
return
fileName
.
startsWith
(
prefix
);
}
public
OutputStream
newOutputStream
(
boolean
append
)
{
try
{
File
file
=
new
File
(
name
);
...
...
@@ -338,14 +326,6 @@ public class FilePathDisk extends FilePath {
return
f
;
}
protected
boolean
accepts
()
{
return
true
;
}
public
String
unwrap
(
String
fileName
)
{
return
fileName
;
}
public
String
getScheme
()
{
return
"file"
;
}
...
...
h2/src/main/org/h2/store/fs/FilePathMem.java
浏览文件 @
abc9cec3
...
...
@@ -120,11 +120,6 @@ public class FilePathMem extends FilePath {
// TODO directories are not really supported
}
public
boolean
fileStartsWith
(
String
prefix
)
{
prefix
=
getCanonicalPath
(
prefix
);
return
name
.
startsWith
(
prefix
);
}
public
OutputStream
newOutputStream
(
boolean
append
)
{
try
{
FileObjectMemData
obj
=
getMemoryFile
();
...
...
@@ -161,14 +156,6 @@ public class FilePathMem extends FilePath {
return
name
.
equals
(
getScheme
());
}
protected
boolean
accepts
(
String
fileName
)
{
return
fileName
.
startsWith
(
getScheme
());
}
public
String
unwrap
(
String
fileName
)
{
return
fileName
;
}
private
static
String
getCanonicalPath
(
String
fileName
)
{
fileName
=
fileName
.
replace
(
'\\'
,
'/'
);
int
idx
=
fileName
.
indexOf
(
':'
)
+
1
;
...
...
@@ -182,6 +169,11 @@ public class FilePathMem extends FilePath {
return
"memFS"
;
}
/**
* Whether the file should be compressed.
*
* @return if it should be compressed.
*/
boolean
compressed
()
{
return
false
;
}
...
...
h2/src/main/org/h2/store/fs/FilePathNio.java
浏览文件 @
abc9cec3
...
...
@@ -14,23 +14,10 @@ import java.io.IOException;
*/
public
class
FilePathNio
extends
FilePathWrapper
{
/**
* Try to open a file with this name and mode.
*
* @param fileName the file name
* @param mode the open mode
* @return the file object
* @throws IOException if opening fails
*/
protected
FileObject
open
(
String
fileName
,
String
mode
)
throws
IOException
{
return
new
FileObjectNio
(
fileName
,
mode
);
public
FileObject
openFileObject
(
String
mode
)
throws
IOException
{
return
new
FileObjectNio
(
name
,
mode
);
}
/**
* Get the prefix for this file system.
*
* @return the prefix
*/
public
String
getScheme
()
{
return
"nio"
;
}
...
...
h2/src/main/org/h2/store/fs/FilePathNioMapped.java
浏览文件 @
abc9cec3
...
...
@@ -14,15 +14,10 @@ import java.io.IOException;
*/
public
class
FilePathNioMapped
extends
FilePathNio
{
p
rotected
FileObject
open
(
String
mode
)
throws
IOException
{
p
ublic
FileObject
openFileObject
(
String
mode
)
throws
IOException
{
return
new
FileObjectNioMapped
(
name
,
mode
);
}
/**
* Get the prefix for this file system.
*
* @return the prefix
*/
public
String
getScheme
()
{
return
"nioMapped"
;
}
...
...
h2/src/main/org/h2/store/fs/FilePathWrapper.java
浏览文件 @
abc9cec3
...
...
@@ -24,6 +24,12 @@ public abstract class FilePathWrapper extends FilePath {
return
create
(
path
,
unwrap
(
path
));
}
/**
* Create a wrapped path instance for the given base path.
*
* @param base the base path
* @return the wrapped path
*/
public
FilePathWrapper
wrap
(
FilePath
base
)
{
return
base
==
null
?
null
:
create
(
getPrefix
()
+
base
.
name
,
base
);
}
...
...
@@ -47,6 +53,12 @@ public abstract class FilePathWrapper extends FilePath {
return
getScheme
()
+
":"
;
}
/**
* Get the base path for the given wrapped path.
*
* @param path the path including the scheme prefix
* @return the base file path
*/
protected
FilePath
unwrap
(
String
path
)
{
return
FilePath
.
get
(
path
.
substring
(
getScheme
().
length
()
+
1
));
}
...
...
@@ -75,10 +87,6 @@ public abstract class FilePathWrapper extends FilePath {
return
base
.
exists
();
}
public
boolean
fileStartsWith
(
String
prefix
)
{
return
name
.
startsWith
(
prefix
);
}
public
FilePath
getParent
()
{
return
wrap
(
base
.
getParent
());
}
...
...
h2/src/main/org/h2/store/fs/FilePathZip.java
浏览文件 @
abc9cec3
...
...
@@ -54,10 +54,6 @@ public class FilePathZip extends FilePath {
}
}
public
boolean
fileStartsWith
(
String
fileName
,
String
prefix
)
{
return
fileName
.
startsWith
(
prefix
);
}
public
long
lastModified
()
{
return
0
;
}
...
...
@@ -213,14 +209,6 @@ public class FilePathZip extends FilePath {
return
new
FilePathDisk
().
getPath
(
name
).
createTempFile
(
suffix
,
deleteOnExit
,
true
);
}
// protected boolean accepts(String fileName) {
// return fileName.startsWith(PREFIX);
// }
public
boolean
fileStartsWith
(
String
prefix
)
{
return
name
.
startsWith
(
prefix
);
}
public
String
getScheme
()
{
return
"zip"
;
}
...
...
h2/src/main/org/h2/store/fs/FileUtils.java
浏览文件 @
abc9cec3
...
...
@@ -9,11 +9,11 @@ import org.h2.message.DbException;
import
org.h2.util.IOUtils
;
/**
* This utility class contains utility functions that use the file system abstraction.
* This utility class contains utility functions that use the file system
* abstraction.
*/
public
class
FileUtils
{
/**
* Checks if a file exists.
* This method is similar to Java 7 <code>java.nio.file.Path.exists</code>.
...
...
@@ -237,17 +237,6 @@ public class FileUtils {
return
FilePath
.
get
(
fileName
).
unwrap
().
toString
();
}
/**
* Check if a file starts with a given prefix.
*
* @param fileName the complete file name
* @param prefix the prefix
* @return true if it starts with the prefix
*/
public
static
boolean
fileStartsWith
(
String
fileName
,
String
prefix
)
{
return
FilePath
.
get
(
fileName
).
fileStartsWith
(
prefix
);
}
// utility methods =======================================
/**
...
...
h2/src/test/org/h2/test/utils/FilePathDebug.java
浏览文件 @
abc9cec3
...
...
@@ -76,11 +76,6 @@ public class FilePathDebug extends FilePathWrapper {
return
super
.
exists
();
}
public
boolean
fileStartsWith
(
String
prefix
)
{
trace
(
name
,
"fileStartsWith"
,
unwrap
(
prefix
));
return
super
.
fileStartsWith
(
prefix
);
}
public
String
getName
()
{
trace
(
name
,
"getName"
);
return
super
.
getName
();
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
abc9cec3
...
...
@@ -692,5 +692,5 @@ unusual apfel caught overcareful tricky nodep junit eventually concrete
enhancer banana nit cglib challenging intercepted banane assertthrows
objenesis prepend detecting overridable eater forgetting tear
fork tester jaspa redirection johnny brings gone jooq iciql offline pdo mappings largely
pst patadia summertime jalpesh
pst patadia summertime jalpesh
scheme compilable
h2/src/tools/org/h2/dev/fs/FilePathCrypt.java
浏览文件 @
abc9cec3
...
...
@@ -22,6 +22,9 @@ import org.h2.store.fs.FileUtils;
*/
public
class
FilePathCrypt
extends
FilePathWrapper
{
/**
* Register this file system.
*/
public
static
void
register
()
{
FilePath
.
register
(
new
FilePathCrypt
());
}
...
...
h2/src/tools/org/h2/dev/fs/FilePathZip2.java
浏览文件 @
abc9cec3
...
...
@@ -297,10 +297,6 @@ public class FilePathZip2 extends FilePath {
return
FilePathDisk
.
expandUserHomeDirectory
(
fileName
);
}
public
boolean
fileStartsWith
(
String
prefix
)
{
return
name
.
startsWith
(
prefix
);
}
public
String
getScheme
()
{
return
"zip2"
;
}
...
...
h2/src/tools/org/h2/dev/ftp/server/FtpData.java
浏览文件 @
abc9cec3
...
...
@@ -88,7 +88,6 @@ public class FtpData extends Thread {
/**
* Read a file from a client.
*
* @param fs the target file system
* @param fileName the target file name
*/
synchronized
void
receive
(
String
fileName
)
throws
IOException
{
...
...
@@ -108,7 +107,6 @@ public class FtpData extends Thread {
* Send a file to the client. This method waits until the client has
* connected.
*
* @param fs the source file system
* @param fileName the source file name
* @param skip the number of bytes to skip
*/
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论