public UndoableMapModel CreateFromHpi(string hpipath, string mappath, bool readOnly) { MapModel m; using (var hpi = new HpiArchive(hpipath)) { var otaPath = HpiPath.ChangeExtension(mappath, ".ota"); TdfNode n; var otaFileInfo = hpi.FindFile(otaPath); var otaFileBuffer = new byte[otaFileInfo.Size]; hpi.Extract(otaFileInfo, otaFileBuffer); using (var ota = new MemoryStream(otaFileBuffer)) { n = TdfNode.LoadTdf(ota); } var tntFileInfo = hpi.FindFile(mappath); var tntFileBuffer = new byte[tntFileInfo.Size]; hpi.Extract(tntFileInfo, tntFileBuffer); using (var s = new TntReader(new MemoryStream(tntFileBuffer))) { m = this.mapModelFactory.FromTntAndOta(s, n); } } return(new UndoableMapModel(m, hpipath, readOnly)); }
private MapTile LoadSectionFromDisk(string hpiFileName, string sctFileName) { var outpath = Path.GetTempFileName(); try { byte[] fileBuffer; using (var h = new HpiArchive(hpiFileName)) { var fileInfo = h.FindFile(sctFileName); fileBuffer = new byte[fileInfo.Size]; h.Extract(fileInfo, fileBuffer); } using (var s = new SctReader(new MemoryStream(fileBuffer))) { return(this.sectionFactory.TileFromSct(s)); } } finally { File.Delete(outpath); } }