コード例 #1
0
ファイル: Decompressor.cs プロジェクト: giaynhap/ExLol-wad
        // Token: 0x0600001E RID: 30 RVA: 0x000024BC File Offset: 0x000006BC
        public byte[] Unwrap(ArraySegment <byte> src, int maxDecompressedSize = 2147483647)
        {
            if (src.Count == 0)
            {
                return(new byte[0]);
            }
            ulong decompressedSize = Decompressor.GetDecompressedSize(src);

            if (decompressedSize == 0UL)
            {
                throw new ZstdException("Can't create buffer for data with unspecified decompressed size (provide your own buffer to Unwrap instead)");
            }
            if (decompressedSize > (ulong)((long)maxDecompressedSize))
            {
                throw new ArgumentOutOfRangeException(string.Format("Decompressed size is too big ({0} bytes > authorized {1} bytes)", decompressedSize, maxDecompressedSize));
            }
            byte[] array = new byte[decompressedSize];
            int    num;

            try
            {
                num = this.Unwrap(src, array, 0, false);
            }
            catch (InsufficientMemoryException)
            {
                throw new ZstdException("Invalid decompressed size");
            }
            if ((int)decompressedSize != num)
            {
                throw new ZstdException("Invalid decompressed size specified in the data");
            }
            return(array);
        }
コード例 #2
0
ファイル: Decompressor.cs プロジェクト: giaynhap/ExLol-wad
 // Token: 0x0600001F RID: 31 RVA: 0x00002554 File Offset: 0x00000754
 public static ulong GetDecompressedSize(byte[] src)
 {
     return(Decompressor.GetDecompressedSize(new ArraySegment <byte>(src)));
 }