Beispiel #1
0
        private void ReadPre530Metadata(EndianReader reader)
        {
            switch (Header.Type)
            {
            case BundleType.UnityRaw:
            {
                Metadata = new BundleMetadata(m_filePath);
                Metadata.ReadPre530(reader);
            }
            break;

            case BundleType.UnityWeb:
            case BundleType.HexFA:
            {
                // read only last chunk. wtf?
                ChunkInfo chunkInfo = Header.ChunkInfos[Header.ChunkInfos.Count - 1];
                using (SmartStream stream = SmartStream.CreateMemory(new byte[chunkInfo.DecompressedSize]))
                {
                    SevenZipHelper.DecompressLZMASizeStream(reader.BaseStream, chunkInfo.CompressedSize, stream);
                    Metadata = new BundleMetadata(m_filePath);
                    using (EndianReader decompressReader = new EndianReader(stream, EndianType.BigEndian))
                    {
                        Metadata.ReadPre530(decompressReader);
                    }
                }
            }
            break;

            default:
                throw new NotSupportedException($"Bundle type {Header.Type} isn't supported before 530 generation");
            }
        }
        private SmartStream ReadPre530Metadata(BundleFileReader reader)
        {
            switch (Header.Type)
            {
            case BundleType.UnityRaw:
            {
                Metadata.Read(reader);
                return(m_stream.CreateReference());
            }

            case BundleType.UnityWeb:
            {
                // read only last chunk. wtf?
                ChunkInfo chunkInfo = Header.ChunkInfos[Header.ChunkInfos.Count - 1];
                using (SmartStream stream = SmartStream.CreateMemory(new byte[chunkInfo.DecompressedSize]))
                {
                    SevenZipHelper.DecompressLZMASizeStream(reader.BaseStream, chunkInfo.CompressedSize, stream);
                    using (BundleFileReader decompressReader = new BundleFileReader(stream, reader.EndianType, reader.Generation))
                    {
                        Metadata.Read(decompressReader);
                    }
                    return(stream.CreateReference());
                }
            }

            default:
                throw new NotSupportedException($"Bundle type {Header.Type} isn't supported before 530 generation");
            }
        }