示例#1
0
        public static byte[] Decompress(byte[] inputBytes, ICodeProgress progress)
        {
            MemoryStream newInStream = new MemoryStream(inputBytes);

            SevenZipRadical.Compression.LZMA.Decoder decoder = new SevenZipRadical.Compression.LZMA.Decoder();

            newInStream.Seek(0, 0);
            MemoryStream newOutStream = new MemoryStream();

            byte[] properties2 = new byte[5];
            if (newInStream.Read(properties2, 0, 5) != 5)
            {
                throw (new Exception("input .lzma is too short"));
            }
            long outSize = 0;

            for (int i = 0; i < 8; i++)
            {
                int v = newInStream.ReadByte();
                if (v < 0)
                {
                    throw (new Exception("Can't Read 1"));
                }
                outSize |= ((long)(byte)v) << (8 * i);
            }
            decoder.SetDecoderProperties(properties2);

            long compressedSize = dataProcessingSize = newInStream.Length - newInStream.Position;

            decoder.Code(newInStream, newOutStream, compressedSize, outSize, progress);

            byte[] b = newOutStream.ToArray();

            return(b);
        }
        public static byte[] Decompress(byte[] inputBytes, ICodeProgress progress)
        {
            MemoryStream newInStream = new MemoryStream(inputBytes);

            SevenZipRadical.Compression.LZMA.Decoder decoder = new SevenZipRadical.Compression.LZMA.Decoder();

            newInStream.Seek(0, 0);
            MemoryStream newOutStream = new MemoryStream();

            byte[] properties2 = new byte[5];
            if (newInStream.Read(properties2, 0, 5) != 5)
                throw (new Exception("input .lzma is too short"));
            long outSize = 0;
            for (int i = 0; i < 8; i++)
            {
                int v = newInStream.ReadByte();
                if (v < 0)
                    throw (new Exception("Can't Read 1"));
                outSize |= ((long)(byte)v) << (8 * i);
            }
            decoder.SetDecoderProperties(properties2);

            long compressedSize = dataProcessingSize = newInStream.Length - newInStream.Position;
            decoder.Code(newInStream, newOutStream, compressedSize, outSize, progress);

            byte[] b = newOutStream.ToArray();

            return b;
        }