private void ReadPre530Metadata(EndianStream stream, bool isClosable) { switch (Header.Type) { case BundleType.UnityRaw: { if (Header.ChunkInfos.Count > 1) { throw new NotSupportedException($"Raw data with several chunks {Header.ChunkInfos.Count} isn't supported"); } BundleMetadata metadata = new BundleMetadata(stream.BaseStream, m_filePath, isClosable); metadata.ReadPre530(stream); Metadatas = new BundleMetadata[] { metadata }; } break; case BundleType.UnityWeb: case BundleType.HexFA: { BundleMetadata[] metadatas = new BundleMetadata[Header.ChunkInfos.Count]; for (int i = 0; i < Header.ChunkInfos.Count; i++) { ChunkInfo chunkInfo = Header.ChunkInfos[i]; MemoryStream memStream = new MemoryStream(new byte[chunkInfo.DecompressedSize]); SevenZipHelper.DecompressLZMASizeStream(stream.BaseStream, chunkInfo.CompressedSize, memStream); BundleMetadata metadata = new BundleMetadata(memStream, m_filePath, true); using (EndianStream decompressStream = new EndianStream(memStream, EndianType.BigEndian)) { metadata.ReadPre530(decompressStream); } metadatas[i] = metadata; } Metadatas = metadatas; if (isClosable) { stream.Dispose(); } } break; default: throw new NotSupportedException($"Bundle type {Header.Type} isn't supported before 530 generation"); } }
private void ReadPre530Metadata(EndianReader reader) { switch (Header.Type) { case BundleType.UnityRaw: { if (Header.ChunkInfos.Count > 1) { throw new NotSupportedException($"Raw data with several chunks {Header.ChunkInfos.Count} isn't supported"); } 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"); } }