コード例 #1
0
ファイル: BundleFileScheme.cs プロジェクト: zbx91/UtinyRipper
        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");
            }
        }
コード例 #2
0
ファイル: BundleFile.cs プロジェクト: zhejimanyu/UtinyRipper
        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");
            }
        }
コード例 #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());
     }
 }
コード例 #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());
     }
 }
コード例 #5
0
ファイル: ArchiveFile.cs プロジェクト: xiaolinfu/UtinyRipper
        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);
            }
        }
コード例 #6
0
ファイル: ArchiveFile.cs プロジェクト: xiaolinfu/UtinyRipper
        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);
            }
        }
コード例 #7
0
ファイル: BundleFileScheme.cs プロジェクト: zbx91/UtinyRipper
 private SmartStream CreateStream(long decompressedSize)
 {
     return(decompressedSize > int.MaxValue ? SmartStream.CreateTemp() : SmartStream.CreateMemory(new byte[decompressedSize]));
 }