throws IOException
{
if (!exists(directory))
throw new IOException("File does not exist: " + getName());
Dbc cursor = null;
try {
try {
byte[] bytes = getKey();
int ulen = bytes.length + 8;
byte[] cursorBytes = new byte[ulen];
DatabaseEntry cursorKey = new DatabaseEntry(cursorBytes);
DatabaseEntry cursorData = new DatabaseEntry((byte[]) null);
Db files = directory.files;
Db blocks = directory.blocks;
DbTxn txn = directory.txn;
int flags = directory.flags;
System.arraycopy(bytes, 0, cursorBytes, 0, bytes.length);
cursorKey.setUserBuffer(ulen, true);
cursorData.setPartial(true);
cursor = blocks.cursor(txn, flags);
if (cursor.get(cursorKey, cursorData,
DbConstants.DB_SET_RANGE | flags) != DbConstants.DB_NOTFOUND)
{
cursor.del(0);
outer:
while (cursor.get(cursorKey, cursorData,
DbConstants.DB_NEXT | flags) != DbConstants.DB_NOTFOUND)
{
for (int i = 0; i < bytes.length; i++)
if (bytes[i] != cursorBytes[i])
break outer;
cursor.del(0);
}
}
files.del(txn, key, 0);
} finally {
if (cursor != null)
cursor.close();
}
} catch (DatabaseException e) {
throw new IOException(e.getMessage());
}
}