Beispiel #1
0
        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");
            }
        }
Beispiel #2
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");
            }
        }
Beispiel #3
0
 private SmartStream ReadBrotli(EndianReader reader)
 {
     using (SmartStream stream = SmartStream.CreateMemory())
     {
         using (BrotliInputStream brotliStream = new BrotliInputStream(reader.BaseStream))
         {
             brotliStream.CopyTo(stream);
         }
         return(stream.CreateReference());
     }
 }
Beispiel #4
0
 private SmartStream ReadGZip(EndianReader reader)
 {
     using (SmartStream stream = SmartStream.CreateMemory())
     {
         using (GZipStream gzipStream = new GZipStream(reader.BaseStream, CompressionMode.Decompress))
         {
             gzipStream.CopyTo(stream);
         }
         return(stream.CreateReference());
     }
 }
Beispiel #5
0
        private void ReadBrotli(EndianReader reader)
        {
            using (SmartStream stream = SmartStream.CreateMemory())
            {
                using (BrotliInputStream brotliStream = new BrotliInputStream(reader.BaseStream))
                {
                    brotliStream.CopyStream(stream);
                    stream.Position = 0;
                }

                string           name  = Path.GetFileName(m_filePath);
                ArchiveFileEntry entry = new ArchiveFileEntry(stream, m_filePath, name, 0, stream.Length);
                Metadata = new ArchiveMetadata(entry);
            }
        }
Beispiel #6
0
        private void ReadGZip(EndianReader reader)
        {
            using (SmartStream stream = SmartStream.CreateMemory())
            {
                using (GZipStream gzipStream = new GZipStream(reader.BaseStream, CompressionMode.Decompress))
                {
                    gzipStream.CopyTo(stream);
                    stream.Position = 0;
                }

                string           name  = Path.GetFileName(m_filePath);
                ArchiveFileEntry entry = new ArchiveFileEntry(stream, m_filePath, name, 0, stream.Length);
                Metadata = new ArchiveMetadata(entry);
            }
        }
Beispiel #7
0
 private SmartStream CreateStream(long decompressedSize)
 {
     return(decompressedSize > int.MaxValue ? SmartStream.CreateTemp() : SmartStream.CreateMemory(new byte[decompressedSize]));
 }