private void verifyVersionInfo() throws IOException { String versionInfoPath = myExePath + ".version"; RandomAccessFile versionInfoStream = new RandomAccessFile(versionInfoPath, "rw"); try { myVersionInfo.resetOffsets(0); myVersionInfo.write(versionInfoStream); } finally { versionInfoStream.close(); } VersionInfo copy = new VersionInfo(); copy.read( new OffsetTrackingInputStream(new DataInputStream(new FileInputStream(versionInfoPath)))); }
public void load() throws IOException { RandomAccessFile stream = new RandomAccessFile(myTemplate, "r"); ExeReader formatReader = new ExeReader(myTemplate.getName(), ExeFormat.UNKNOWN); formatReader.read(stream); stream.seek(0L); myReader = new ExeReader(myTemplate.getName(), formatReader.getExeFormat()); myReader.read(stream); stream.close(); SectionReader sectionReader = myReader.getSectionReader(".rsrc"); ResourceSectionReader resourceReader = (ResourceSectionReader) sectionReader.getMember(".rsrc"); myRoot = resourceReader.getRoot(); DirectoryEntry subDir = myRoot.findSubDir("IRD6"); myStringTableDirectory = new StringTableDirectory(subDir); RawResource versionInfoResource = getVersionInfoResource(); ByteArrayInputStream bytesStream = new ByteArrayInputStream(versionInfoResource.getBytes().getBytes()); myVersionInfo = new VersionInfo(); myVersionInfo.read(new OffsetTrackingInputStream(new DataInputStream(bytesStream))); }