コード例 #1
0
ファイル: Lzma2Enc.cs プロジェクト: yamiM0NSTER/managed-lzma
            internal SRes Lzma2Enc_EncodeMt1(CLzma2Enc mainEncoder, ISeqOutStream outStream, ISeqInStream inStream, ICompressProgress progress)
            {
                ulong packTotal = 0;
                SRes  res       = SZ_OK;

                if (mainEncoder.mOutBuf == null)
                {
                    mainEncoder.mOutBuf = IAlloc_AllocBytes(mainEncoder.mAlloc, LZMA2_CHUNK_SIZE_COMPRESSED_MAX);
                    if (mainEncoder.mOutBuf == null)
                    {
                        return(SZ_ERROR_MEM);
                    }
                }

                if ((res = Lzma2EncInt_Init(mainEncoder.mProps)) != SZ_OK)
                {
                    return(res);
                }

                if ((res = mEnc.LzmaEnc_PrepareForLzma2(inStream, LZMA2_KEEP_WINDOW_SIZE, mainEncoder.mAlloc, mainEncoder.mAllocBig)) != SZ_OK)
                {
                    return(res);
                }

                for (;;)
                {
                    long packSize = LZMA2_CHUNK_SIZE_COMPRESSED_MAX;
                    res = Lzma2EncInt_EncodeSubblock(mainEncoder.mOutBuf, ref packSize, outStream);
                    if (res != SZ_OK)
                    {
                        break;
                    }
                    packTotal += (ulong)packSize;
                    res        = Progress(progress, mSrcPos, packTotal);
                    if (res != SZ_OK)
                    {
                        break;
                    }
                    if (packSize == 0)
                    {
                        break;
                    }
                }

                mEnc.LzmaEnc_Finish();

                if (res == SZ_OK)
                {
                    if (outStream.Write(new byte[] { 0 }, 1) != 1)
                    {
                        return(SZ_ERROR_WRITE);
                    }
                }

                return(res);
            }
コード例 #2
0
ファイル: Lzma2Enc.cs プロジェクト: yamiM0NSTER/managed-lzma
 internal CMtCallbackImp(CLzma2Enc enc)
 {
     mLzma2Enc = enc;
 }
コード例 #3
0
ファイル: Lzma2Enc.cs プロジェクト: modulexcite/managed-lzma
 internal CMtCallbackImp(CLzma2Enc enc)
 {
     mLzma2Enc = enc;
 }
コード例 #4
0
ファイル: Lzma2Enc.cs プロジェクト: modulexcite/managed-lzma
            internal SRes Lzma2Enc_EncodeMt1(CLzma2Enc mainEncoder, ISeqOutStream outStream, ISeqInStream inStream, ICompressProgress progress)
            {
                ulong packTotal = 0;
                SRes res = SZ_OK;

                if (mainEncoder.mOutBuf == null)
                {
                    mainEncoder.mOutBuf = IAlloc_AllocBytes(mainEncoder.mAlloc, LZMA2_CHUNK_SIZE_COMPRESSED_MAX);
                    if (mainEncoder.mOutBuf == null)
                        return SZ_ERROR_MEM;
                }

                if ((res = Lzma2EncInt_Init(mainEncoder.mProps)) != SZ_OK)
                    return res;

                if ((res = mEnc.LzmaEnc_PrepareForLzma2(inStream, LZMA2_KEEP_WINDOW_SIZE, mainEncoder.mAlloc, mainEncoder.mAllocBig)) != SZ_OK)
                    return res;

                for (;;)
                {
                    long packSize = LZMA2_CHUNK_SIZE_COMPRESSED_MAX;
                    res = Lzma2EncInt_EncodeSubblock(mainEncoder.mOutBuf, ref packSize, outStream);
                    if (res != SZ_OK)
                        break;
                    packTotal += (ulong)packSize;
                    res = Progress(progress, mSrcPos, packTotal);
                    if (res != SZ_OK)
                        break;
                    if (packSize == 0)
                        break;
                }

                mEnc.LzmaEnc_Finish();

                if (res == SZ_OK)
                {
                    if (outStream.Write(new byte[] { 0 }, 1) != 1)
                        return SZ_ERROR_WRITE;
                }

                return res;
            }