Esempio n. 1
0
            /*
             * finishMode:
             * It has meaning only if the decoding reaches output limit (*destLen).
             * LZMA_FINISH_ANY - use smallest number of input bytes
             * LZMA_FINISH_END - read EndOfStream marker after decoding
             *
             * Returns:
             * SZ_OK
             *  status:
             *    LZMA_STATUS_FINISHED_WITH_MARK
             *    LZMA_STATUS_NOT_FINISHED
             * SZ_ERROR_DATA - Data error
             * SZ_ERROR_MEM  - Memory allocation error
             * SZ_ERROR_UNSUPPORTED - Unsupported properties
             * SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
             */

            public static SRes Lzma2Decode(P <byte> dest, ref long destLen, P <byte> src, ref long srcLen, byte prop, ELzmaFinishMode finishMode, out ELzmaStatus status, ISzAlloc alloc)
            {
                long outSize = destLen;
                long inSize  = srcLen;

                destLen = 0;
                srcLen  = 0;
                status  = ELzmaStatus.LZMA_STATUS_NOT_SPECIFIED;

                CLzma2Dec p = new CLzma2Dec();

                p.Lzma2Dec_Construct();
                SRes res;

                if ((res = p.Lzma2Dec_AllocateProbs(prop, alloc)) != SZ_OK)
                {
                    return(res);
                }
                p.mDecoder.mDic        = dest;
                p.mDecoder.mDicBufSize = outSize;
                p.Lzma2Dec_Init();
                srcLen  = inSize;
                res     = p.Lzma2Dec_DecodeToDic(outSize, src, ref srcLen, finishMode, out status);
                destLen = p.mDecoder.mDicPos;
                if (res == SZ_OK && status == ELzmaStatus.LZMA_STATUS_NEEDS_MORE_INPUT)
                {
                    res = SZ_ERROR_INPUT_EOF;
                }
                p.Lzma2Dec_FreeProbs(alloc);
                return(res);
            }
Esempio n. 2
0
            /*
            finishMode:
              It has meaning only if the decoding reaches output limit (*destLen).
              LZMA_FINISH_ANY - use smallest number of input bytes
              LZMA_FINISH_END - read EndOfStream marker after decoding

            Returns:
              SZ_OK
                status:
                  LZMA_STATUS_FINISHED_WITH_MARK
                  LZMA_STATUS_NOT_FINISHED
              SZ_ERROR_DATA - Data error
              SZ_ERROR_MEM  - Memory allocation error
              SZ_ERROR_UNSUPPORTED - Unsupported properties
              SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
            */
            public static SRes Lzma2Decode(P<byte> dest, ref long destLen, P<byte> src, ref long srcLen, byte prop, ELzmaFinishMode finishMode, out ELzmaStatus status, ISzAlloc alloc)
            {
                long outSize = destLen;
                long inSize = srcLen;
                destLen = 0;
                srcLen = 0;
                status = ELzmaStatus.LZMA_STATUS_NOT_SPECIFIED;

                CLzma2Dec p = new CLzma2Dec();
                p.Lzma2Dec_Construct();
                SRes res;
                if ((res = p.Lzma2Dec_AllocateProbs(prop, alloc)) != SZ_OK)
                    return res;
                p.mDecoder.mDic = dest;
                p.mDecoder.mDicBufSize = outSize;
                p.Lzma2Dec_Init();
                srcLen = inSize;
                res = p.Lzma2Dec_DecodeToDic(outSize, src, ref srcLen, finishMode, out status);
                destLen = p.mDecoder.mDicPos;
                if (res == SZ_OK && status == ELzmaStatus.LZMA_STATUS_NEEDS_MORE_INPUT)
                    res = SZ_ERROR_INPUT_EOF;
                p.Lzma2Dec_FreeProbs(alloc);
                return res;
            }