提交 2d0fcdd6 authored 作者: Thomas Mueller's avatar Thomas Mueller

Improved compatibility with the Java 7 FileSystem abstraction.

上级 bd76c41e
/*
* Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.store.fs; package org.h2.store.fs;
import java.io.IOException; import java.io.IOException;
......
...@@ -84,7 +84,7 @@ public class FilePathDisk extends FilePath { ...@@ -84,7 +84,7 @@ public class FilePathDisk extends FilePath {
File oldFile = new File(name); File oldFile = new File(name);
File newFile = new File(newName.name); File newFile = new File(newName.name);
if (oldFile.getAbsolutePath().equals(newFile.getAbsolutePath())) { if (oldFile.getAbsolutePath().equals(newFile.getAbsolutePath())) {
DbException.throwInternalError("rename file old=new"); return;
} }
if (!oldFile.exists()) { if (!oldFile.exists()) {
throw DbException.get(ErrorCode.FILE_RENAME_FAILED_2, throw DbException.get(ErrorCode.FILE_RENAME_FAILED_2,
......
/*
* Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.store.fs; package org.h2.store.fs;
import java.io.EOFException; import java.io.EOFException;
......
...@@ -283,6 +283,7 @@ public class TestFileSystem extends TestBase { ...@@ -283,6 +283,7 @@ public class TestFileSystem extends TestBase {
assertTrue(list.get(0).endsWith("test")); assertTrue(list.get(0).endsWith("test"));
FileUtils.copy(fsBase + "/test", fsBase + "/test3"); FileUtils.copy(fsBase + "/test", fsBase + "/test3");
FileUtils.moveTo(fsBase + "/test3", fsBase + "/test2"); FileUtils.moveTo(fsBase + "/test3", fsBase + "/test2");
FileUtils.moveTo(fsBase + "/test2", fsBase + "/test2");
assertTrue(!FileUtils.exists(fsBase + "/test3")); assertTrue(!FileUtils.exists(fsBase + "/test3"));
assertTrue(FileUtils.exists(fsBase + "/test2")); assertTrue(FileUtils.exists(fsBase + "/test2"));
assertEquals(10000, FileUtils.size(fsBase + "/test2")); assertEquals(10000, FileUtils.size(fsBase + "/test2"));
...@@ -354,9 +355,9 @@ public class TestFileSystem extends TestBase { ...@@ -354,9 +355,9 @@ public class TestFileSystem extends TestBase {
case 2: { case 2: {
trace("truncate " + pos); trace("truncate " + pos);
f.truncate(pos); f.truncate(pos);
if (pos < ra.getFilePointer()) { if (pos < ra.length()) {
// truncate is supposed to have no effect if the // truncate is supposed to have no effect if the
// position is larger than the current position // position is larger than the current size
ra.setLength(pos); ra.setLength(pos);
} }
assertEquals(ra.getFilePointer(), f.position()); assertEquals(ra.getFilePointer(), f.position());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论