Exemple #1
0
        public static void Decompress(Stream newInStream, Stream newOutStream)
        {
            lock (m_DecoderLock)
            {
                if (m_Decoder == null)
                {
                    m_Decoder = new LzmaDecoder();
                }

                if (m_DecoderProps == null)
                {
                    m_DecoderProps = new byte[5];
                }
                if (newInStream.Read(m_DecoderProps, 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);
                }

                m_Decoder.SetDecoderProperties(m_DecoderProps);
                long compressedSize = newInStream.Length - newInStream.Position;
                m_Decoder.Code(newInStream, newOutStream, compressedSize, outSize, null);
            }
        }
Exemple #2
0
        public static void Decompress(Stream newInStream, Stream newOutStream)
        {
            lock (m_DecoderLock)
            {
                if (m_Decoder == null)
                {
                    m_Decoder = new LzmaDecoder();
                }

                if (m_DecoderProps == null)
                {
                    m_DecoderProps = new byte[5];
                }
                if (newInStream.Read(m_DecoderProps, 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);
                }

                m_Decoder.SetDecoderProperties(m_DecoderProps);
                long compressedSize = newInStream.Length - newInStream.Position;
                m_Decoder.Code(newInStream, newOutStream, compressedSize, outSize, null);
            }
        }