add version check, smaller size version info
This commit is contained in:
parent
d315f4e33e
commit
fbc01c0ba9
1 changed files with 22 additions and 1 deletions
|
@ -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
|
* Checks the integrity of the file using the build-in checksums
|
||||||
*
|
*
|
||||||
|
@ -81,7 +102,7 @@ final public class PhysicalFile {
|
||||||
short readVersion = (short) (lv >> 48);
|
short readVersion = (short) (lv >> 48);
|
||||||
if (i == 0 && lookupVersion != -1 && readVersion != lookupVersion) {
|
if (i == 0 && lookupVersion != -1 && readVersion != lookupVersion) {
|
||||||
throw new IOException("lookup version mismatch (old rd5?) lookups.dat="
|
throw new IOException("lookup version mismatch (old rd5?) lookups.dat="
|
||||||
+ lookupVersion + " " + f.getAbsolutePath() + "=" + readVersion);
|
+ lookupVersion + " " + f.getName() + "=" + readVersion);
|
||||||
}
|
}
|
||||||
fileIndex[i] = lv & 0xffffffffffffL;
|
fileIndex[i] = lv & 0xffffffffffffL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue