internal static void DecompressStreamToStream(Stream inStream, Stream outStream)
        {
#if iOS
            lock (staticEncoderLocker)
            {
                LZMA.Decoder decoder = staticDecoder;
#else
            LZMA.Decoder decoder = new LZMA.Decoder();
#endif

            inStream.Seek(0, 0);

            byte[] properties2 = new byte[5];
            if (inStream.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 = inStream.ReadByte();
                if (v < 0)
                    throw (new Exception("Can't Read 1"));
                outSize |= ((long)(byte)v) << (8 * i);
            }
            decoder.SetDecoderProperties(properties2);

            long compressedSize = inStream.Length - inStream.Position;
            decoder.Code(inStream, outStream, compressedSize, outSize);

#if iOS
            }
#endif
        }
        internal static byte[] Decompress(byte[] inputBytes)
        {
#if iOS
            lock (staticEncoderLocker)
            {
                LZMA.Decoder decoder = staticDecoder;
#else
            LZMA.Decoder decoder = new LZMA.Decoder();
#endif

            MemoryStream newInStream = new MemoryStream(inputBytes);
            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 = newInStream.Length - newInStream.Position;
            decoder.Code(newInStream, newOutStream, compressedSize, outSize);

            byte[] b = newOutStream.ToArray();

            return b;

#if iOS
            }
#endif
        }
 public LzmaArchiveDecoder(ImmutableArray<byte> settings, long length)
 {
     mDecoder = new LZMA.Decoder(LZMA.DecoderSettings.CreateFrom(settings));
     mOutput = new OutputStream(this);
     mOutputLength = length;
 }
        internal static void DecompressStreamToStream(Stream inStream, Stream outStream)
        {
#if iOS
            lock (staticEncoderLocker)
            {
                LZMA.Decoder decoder = staticDecoder;
#else
                LZMA.Decoder decoder = new LZMA.Decoder();
#endif

            inStream.Seek(0, 0);

            byte[] properties2 = new byte[5];
            if (inStream.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 = inStream.ReadByte();
                if (v < 0)
                    throw (new Exception("Can't Read 1"));
                outSize |= ((long)(byte)v) << (8 * i);
            }
            decoder.SetDecoderProperties(properties2);

            long compressedSize = inStream.Length - inStream.Position;
            decoder.Code(inStream, outStream, compressedSize, outSize);

#if iOS
            }
#endif
        }
        internal static byte[] DecompressFromStream(Stream newInStream)
        {
#if iOS
            lock (staticEncoderLocker)
            {
                LZMA.Decoder decoder = staticDecoder;
#else
                LZMA.Decoder decoder = new LZMA.Decoder();
#endif

            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 = newInStream.Length - newInStream.Position;
            decoder.Code(newInStream, newOutStream, compressedSize, outSize);

            byte[] b = newOutStream.ToArray();

            return b;

#if iOS
            }
#endif
        }
Exemple #6
0
 public LzmaArchiveDecoder(ImmutableArray <byte> settings, long length)
 {
     mDecoder      = new LZMA.Decoder(LZMA.DecoderSettings.CreateFrom(settings));
     mOutput       = new OutputStream(this);
     mOutputLength = length;
 }