public void Load(System.IO.Stream stream) { _stream = stream; using (var reader = new Toolbox.Library.IO.FileReader(stream, true)) { reader.SetByteOrder(true); var header = reader.ReadStruct <MSBTHeader>(); Text = FileName; //parse the data int index = 0; while (!reader.EndOfStream) { CChunkDescriptor chunk = reader.ReadStruct <CChunkDescriptor>(); long startPos = reader.Position; reader.SeekBegin(startPos + (int)chunk.DataOffset); var subStream = new SubStream(_stream, reader.Position, (long)chunk.DataSize); Nodes.Add(new MessageEntry(subStream, index++, chunk.ChunkType)); reader.SeekBegin(startPos + (int)chunk.DataOffset + (int)chunk.DataSize); } } }
private void ReadMetaChunk(FileReader reader, CChunkDescriptor chunk) { if (chunk.ChunkType != "META") { throw new Exception("Unexpected type! Expected META, got " + chunk.ChunkType); } long pos = reader.Position; reader.SeekBegin(pos + chunk.DataOffset); uint numEntries = reader.ReadUInt32(); for (int i = 0; i < numEntries; i++) { MetaOffsetEntry entry = reader.ReadStruct <MetaOffsetEntry>(); MetaOffsets.Add(entry); } reader.SeekBegin(pos + chunk.DataSize); }
private void ReadFileNameChunk(FileReader reader, CChunkDescriptor chunk) { if (chunk.ChunkType != "STRG") { throw new Exception("Unexpected type! Expected STRG, got " + chunk.ChunkType); } long pos = reader.Position; reader.SeekBegin(pos + chunk.DataOffset); uint numEntries = reader.ReadUInt32(); for (int i = 0; i < numEntries; i++) { // CNameTagEntry entry = reader.ReadStruct<CNameTagEntry>(); // FileNameEntries.Add(entry); } reader.SeekBegin(pos + chunk.DataSize); }
private void ReadAssetDirectoryChunk(FileReader reader, CChunkDescriptor chunk) { if (chunk.ChunkType != "ADIR") { throw new Exception("Unexpected type! Expected ADIR, got " + chunk.ChunkType); } long pos = reader.Position; reader.SeekBegin(pos + chunk.DataOffset); uint numEntries = reader.ReadUInt32(); for (int i = 0; i < numEntries; i++) { DirectoryAssetEntry entry = new DirectoryAssetEntry(); entry.Read(reader); Directories.Add(entry); } reader.SeekBegin(pos + chunk.DataSize); }