* org.tmatesoft.sqljet.core.SqlJetFileType, java.util.Set)
*/
public void open(File filename, ISqlJetDbHandle db, Set<SqlJetBtreeFlags> flags, final SqlJetFileType type,
final Set<SqlJetFileOpenPermission> permissions) throws SqlJetException {
ISqlJetFileSystem pVfs; /* The VFS to use for this btree */
SqlJetBtreeShared pBt = null; /* Shared part of btree structure */
int nReserve;
ISqlJetMemoryPointer zDbHeader = SqlJetUtility.allocatePtr(100);
/*
* Set the variable isMemdb to true for an in-memory database, or false
* for a file-based database. This symbol is only required if either of
* the shared-data or autovacuum features are compiled into the library.
*/
final boolean isMemdb = filename != null && ISqlJetPager.MEMORY_DB.equals(filename.getPath());
assert (db != null);
pVfs = db.getFileSystem();
this.inTrans = TransMode.NONE;
this.db = db;
/*
* If this Btree is a candidate for shared cache, try to find an
* existing BtShared object that we can share with
*/
if (!isMemdb && !db.getFlags().contains(SqlJetDbFlags.Vtab) && filename != null
&& !"".equals(filename.getPath())) {
if (db.getConfig().isSharedCacheEnabled()) {
this.sharable = true;
db.getFlags().add(SqlJetDbFlags.SharedCache);
final String fullPathname = pVfs.getFullPath(filename);
synchronized (sharedCacheList) {
final Iterator<SqlJetBtreeShared> i = sharedCacheList.iterator();
while (i.hasNext()) {
pBt = i.next();
assert (pBt.nRef > 0);
final String pagerFilename = pVfs.getFullPath(pBt.pPager.getFileName());
if (fullPathname.equals(pagerFilename) && pVfs == pBt.pPager.getFileSystem()) {
this.pBt = pBt;
pBt.nRef++;
break;
}