diff --git a/brouter-mapaccess/src/main/java/btools/mapaccess/PhysicalFile.java b/brouter-mapaccess/src/main/java/btools/mapaccess/PhysicalFile.java index 921bd31..6b043bd 100644 --- a/brouter-mapaccess/src/main/java/btools/mapaccess/PhysicalFile.java +++ b/brouter-mapaccess/src/main/java/btools/mapaccess/PhysicalFile.java @@ -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; }