The getDataBaseInfo() is missing 1 important line a doesn't used the right seek offset.
public DatabaseInfo getDatabaseInfo() {
if (databaseInfo != null) {
return databaseInfo;
}
try {
// Synchronize since we're accessing the database file.
synchronized (this) {
_check_mtime();
boolean hasStructureInfo = false;
byte [] delim = new byte[3];
// Advance to part of file where database info is stored.
file.seek(file.length() - 3);
for (int i=0; i<STRUCTURE_INFO_MAX_SIZE; i++) {
file.read(delim);
if ((delim[0] & 0xff) == 0xff && (delim[1] & 0xff) == 0xff && (delim[2] & 0xff) == 0xff) { // TrueSight bug fix
hasStructureInfo = true;
break;
}
file.seek(file.getFilePointer() - 4); /////////////// THIS LINE WAS MISSING
}
if (hasStructureInfo) {
file.seek(file.getFilePointer() - 6); ///////////////// THIS WAS getFilePointer() - 3, it must be -6 to make prepare the 0-0-0 search.
}
else {
// No structure info, must be pre Sep 2002 database, go back to end.
file.seek(file.length() - 3);
}
// Find the database info string.
for (int i=0; i<DATABASE_INFO_MAX_SIZE; i++) {
file.read(delim);
if (delim[0]==0 && delim[1]==0 && delim[2]==0) {
byte[] dbInfo = new byte[i];
file.read(dbInfo);
// Create the database info object using the string.
this.databaseInfo = new DatabaseInfo(new String(dbInfo));
return databaseInfo;
}
file.seek(file.getFilePointer() -4);
}
}
}
catch (Exception e) {
e.printStackTrace();
}
return new DatabaseInfo("");
}
also note the use of
if ((delim[0] & 0xff) == 0xff
instead of if(delim[0] = 255
which is ALWAYS FALSE.