コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
ファイル: PAK.cs プロジェクト: week9/Switch-Toolbox
        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);
        }
コード例 #3
0
ファイル: PAK.cs プロジェクト: week9/Switch-Toolbox
        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);
        }
コード例 #4
0
ファイル: PAK.cs プロジェクト: week9/Switch-Toolbox
        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);
        }