add version check, smaller size version info

This commit is contained in:
afischerdev 2023-03-14 14:17:27 +01:00
parent d315f4e33e
commit fbc01c0ba9

View file

@ -37,6 +37,27 @@ final public class PhysicalFile {
}
}
public static int checkVersionIntegrity(File f) {
int version = -1;
RandomAccessFile raf = null;
try {
byte[] iobuffer = new byte[200];
raf = new RandomAccessFile(f, "r");
raf.readFully(iobuffer, 0, 200);
ByteDataReader dis = new ByteDataReader(iobuffer);
long lv = dis.readLong();
version = (int) (lv >> 48);
} catch (IOException e) {
} finally {
try {
if (raf != null) raf.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return version;
}
/**
* Checks the integrity of the file using the build-in checksums
*
@ -81,7 +102,7 @@ final public class PhysicalFile {
short readVersion = (short) (lv >> 48);
if (i == 0 && lookupVersion != -1 && readVersion != lookupVersion) {
throw new IOException("lookup version mismatch (old rd5?) lookups.dat="
+ lookupVersion + " " + f.getAbsolutePath() + "=" + readVersion);
+ lookupVersion + " " + f.getName() + "=" + readVersion);
}
fileIndex[i] = lv & 0xffffffffffffL;
}