public StoreDirect( Volume.Factory volFac, boolean readOnly, boolean deleteFilesAfterClose, int spaceReclaimMode, boolean syncOnCommitDisabled, long sizeLimit, boolean checksum, boolean compress, byte[] password, boolean disableLocks, int sizeIncrement) { super(checksum, compress, password, disableLocks); this.readOnly = readOnly; this.deleteFilesAfterClose = deleteFilesAfterClose; this.syncOnCommitDisabled = syncOnCommitDisabled; this.sizeLimit = sizeLimit; this.spaceReclaimSplit = spaceReclaimMode > 4; this.spaceReclaimReuse = spaceReclaimMode > 2; this.spaceReclaimTrack = spaceReclaimMode > 0; boolean allGood = false; try { index = volFac.createIndexVolume(); phys = volFac.createPhysVolume(); if (index.isEmpty()) { createStructure(); } else { checkHeaders(); indexSize = index.getLong(IO_INDEX_SIZE); physSize = index.getLong(IO_PHYS_SIZE); freeSize = index.getLong(IO_FREE_SIZE); maxUsedIoList = IO_USER_START - 8; while (index.getLong(maxUsedIoList) != 0 && maxUsedIoList > IO_FREE_RECID) maxUsedIoList -= 8; } allGood = true; } finally { if (!allGood) { // exception was thrown, try to unlock files if (index != null) { index.sync(); index.close(); index = null; } if (phys != null) { phys.sync(); phys.close(); phys = null; } } } }