ソースを参照

make read-only logic slightly cleaner


git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@102 f203690c-595d-4dc9-a70b-905162fa7fd2
tags/rel_1_1_7
James Ahlborn 18年前
コミット
2af41c1457
1個のファイルの変更4行の追加4行の削除
  1. 4
    4
      src/java/com/healthmarketscience/jackcess/Database.java

+ 4
- 4
src/java/com/healthmarketscience/jackcess/Database.java ファイルの表示

@@ -203,7 +203,7 @@ public class Database
throw new FileNotFoundException("given file does not exist: " + mdbFile);
}
return new Database(openChannel(mdbFile,
(mdbFile.canWrite() && !readOnly)));
(!mdbFile.canWrite() || readOnly)));
}
/**
@@ -212,17 +212,17 @@ public class Database
* already exists, it will be overwritten.</b>
*/
public static Database create(File mdbFile) throws IOException {
FileChannel channel = openChannel(mdbFile, true);
FileChannel channel = openChannel(mdbFile, false);
channel.transferFrom(Channels.newChannel(
Thread.currentThread().getContextClassLoader().getResourceAsStream(
EMPTY_MDB)), 0, (long) Integer.MAX_VALUE);
return new Database(channel);
}
private static FileChannel openChannel(File mdbFile, boolean needWrite)
private static FileChannel openChannel(File mdbFile, boolean readOnly)
throws FileNotFoundException
{
String mode = (needWrite ? "rw" : "r");
String mode = (readOnly ? "r" : "rw");
return new RandomAccessFile(mdbFile, mode).getChannel();
}

読み込み中…
キャンセル
保存