Esempio n. 1
0
    public void RegistResource(string path, OnResourceReady cb, System.Object callbackObj)
    {
        if (UnityTools.IsPackageResource(path))
        {
            SRes iRes = m_lResKeyList.Find(SRes.MatchPath(path));
            if (iRes != null && iRes.BundleRes.resource != null)
            {
                cb(path, iRes.BundleRes.resource, callbackObj);
            }
            else
            {
                SPendingRequest request = new SPendingRequest();
                request.path = path;
                request.callback = cb;
                request.callbackObj = callbackObj;
                m_ltPendingRequest.Add(request);

                if(null == iRes)
                {
                    iRes = new SRes(path, iLoader.LoadResource(path));
                    m_lResKeyList.Add(iRes);
                    iRes.BundleRes.SetEventListener(HandlePackageResourceEvent);
                }
                //StartCoroutine(TestLoad(path, cb, callbackObj));
            }

        }
        else
        {
            UnityEngine.Object resObj = RegistResource(path);
            //TODO 后续这里加一些判断
            cb(path, resObj, callbackObj);
        }
    }
Esempio n. 2
0
            internal void ThreadFunc()
            {
                for (;;)
                {
                    CMtThread next = GET_NEXT_THREAD();

                    bool stop;
                    SRes res = MtThread_Process(out stop);
                    if (res != SZ_OK)
                    {
                        mMtCoder.MtCoder_SetError(res);
                        mMtCoder.mMtProgress.MtProgress_SetError(res);

                        Trace.MatchObjectWait(this, "ThreadFunc");
                        next.mStopReading = true;
                        next.mStopWriting = true;
                        Trace.MatchObjectWait(this, "ThreadFunc");

                        Event_Set(next.mCanRead);
                        Event_Set(next.mCanWrite);
                        return; // res;
                    }

                    if (stop)
                    {
                        return; // 0;
                    }
                }
            }
Esempio n. 3
0
 internal void MtCoder_SetError(SRes res)
 {
     CriticalSection_Enter(mCS);
     if (mRes == SZ_OK)
     {
         mRes = res;
     }
     CriticalSection_Leave(mCS);
 }
Esempio n. 4
0
            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);
            }
Esempio n. 5
0
            internal SRes MtSync_Create(Action startAddress, string threadName, uint numBlocks)
            {
                SRes res = MtSync_Create2(startAddress, threadName, numBlocks);

                if (res != SZ_OK)
                {
                    MtSync_Destruct();
                }
                return(res);
            }
Esempio n. 6
0
            internal void MtProgress_Init(ICompressProgress progress)
            {
                for (uint i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)
                {
                    mInSizes[i] = mOutSizes[i] = 0;
                }

                mTotalInSize  = 0;
                mTotalOutSize = 0;
                mProgress     = progress;
                mRes          = SZ_OK;
            }
Esempio n. 7
0
            public SRes MtProgress_Set(int index, ulong inSize, ulong outSize)
            {
                CriticalSection_Enter(mCS);
                UPDATE_PROGRESS(inSize, ref mInSizes[index], ref mTotalInSize);
                UPDATE_PROGRESS(outSize, ref mOutSizes[index], ref mTotalOutSize);
                if (mRes == SZ_OK)
                {
                    mRes = Progress(mProgress, mTotalInSize, mTotalOutSize);
                }
                SRes res = mRes;

                CriticalSection_Leave(mCS);
                return(res);
            }
Esempio n. 8
0
            internal static SRes FullRead(ISeqInStream stream, P <byte> data, ref long processedSize)
            {
                long size = processedSize;

                processedSize = 0;
                while (size != 0)
                {
                    long curSize = size;
                    SRes res     = stream.Read(data, ref curSize);
                    processedSize += curSize;
                    data          += curSize;
                    size          -= curSize;
                    if (res != SZ_OK)
                    {
                        return(res);
                    }
                    if (curSize == 0)
                    {
                        return(SZ_OK);
                    }
                }
                return(SZ_OK);
            }
Esempio n. 9
0
            internal SRes LzmaEnc_AllocAndInit(uint keepWindowSize, ISzAlloc alloc, ISzAlloc allocBig)
            {
                {
                    uint i;
                    for (i = 0; i < (uint)kDicLogSizeMaxCompress; i++)
                        if (mDictSize <= (1u << (int)i))
                            break;

                    mDistTableSize = i * 2;
                }

                mFinished = false;
                mResult = SZ_OK;

                SRes res;
                if ((res = LzmaEnc_Alloc(keepWindowSize, alloc, allocBig)) != SZ_OK)
                    return res;

                LzmaEnc_Init();
                LzmaEnc_InitPrices();
                mNowPos64 = 0;
                return SZ_OK;
            }
Esempio n. 10
0
            private SRes CheckErrors()
            {
                if (mResult != SZ_OK)
                    return mResult;

                if (mRC.mRes != SZ_OK)
                    mResult = SZ_ERROR_WRITE;

                if (mMatchFinderBase.mResult != SZ_OK)
                    mResult = SZ_ERROR_READ;

                if (mResult != SZ_OK)
                    mFinished = true;

                return mResult;
            }
Esempio n. 11
0
            internal SRes Code(int index, P <byte> dest, ref long destSize, P <byte> src, long srcSize, bool finished)
            {
                CLzma2EncInternal p = mLzma2Enc.mCoders[index];

                SRes res     = SZ_OK;
                long destLim = destSize;

                destSize = 0;

                if (srcSize != 0)
                {
                    if ((res = p.Lzma2EncInt_Init(mLzma2Enc.mProps)) != SZ_OK)
                    {
                        return(res);
                    }

                    if ((res = p.mEnc.LzmaEnc_MemPrepare(src, srcSize, CLzma2EncInternal.LZMA2_KEEP_WINDOW_SIZE, mLzma2Enc.mAlloc, mLzma2Enc.mAllocBig)) != SZ_OK)
                    {
                        return(res);
                    }

                    while (p.mSrcPos < (ulong)srcSize)
                    {
                        long packSize = destLim - destSize;

                        res = p.Lzma2EncInt_EncodeSubblock(dest + destSize, ref packSize, null);
                        if (res != SZ_OK)
                        {
                            break;
                        }

                        destSize += packSize;

                        if (packSize == 0)
                        {
                            res = SZ_ERROR_FAIL;
                            break;
                        }

                        if (mLzma2Enc.mMtCoder.mMtProgress.MtProgress_Set(index, p.mSrcPos, (ulong)destSize) != SZ_OK)
                        {
                            res = SZ_ERROR_PROGRESS;
                            break;
                        }
                    }

                    p.mEnc.LzmaEnc_Finish();
                    if (res != SZ_OK)
                    {
                        return(res);
                    }
                }

                if (finished)
                {
                    if (destSize == destLim)
                    {
                        return(SZ_ERROR_OUTPUT_EOF);
                    }

                    dest[destSize++] = 0;
                }

                return(res);
            }
Esempio n. 12
0
            private void MatchFinder_ReadBlock()
            {
                if (mStreamEndWasReached || mResult != SZ_OK)
                    return;

                if (mDirectInput)
                {
                    uint curSize = 0xFFFFFFFF - mStreamPos;
                    if (curSize > mDirectInputRem)
                        curSize = (uint)mDirectInputRem;

                    mDirectInputRem -= curSize;
                    mStreamPos += curSize;
                    if (mDirectInputRem == 0)
                        mStreamEndWasReached = true;

                    return;
                }

                for (;;)
                {
                    P<byte> dest = mBuffer + (mStreamPos - mPos);
                    long size = mBufferBase + mBlockSize - dest;
                    if (size == 0)
                        return;

                    mResult = mStream.Read(dest, ref size);
                    if (mResult != SZ_OK)
                        return;

                    if (size == 0)
                    {
                        mStreamEndWasReached = true;
                        return;
                    }

                    mStreamPos += (uint)size;
                    if (mStreamPos - mPos > mKeepSizeAfter)
                        return;
                }
            }
Esempio n. 13
0
            internal SRes Lzma2EncInt_EncodeSubblock(P <byte> outBuf, ref long packSizeRes, ISeqOutStream outStream)
            {
                long packSizeLimit = packSizeRes;
                long packSize      = packSizeLimit;
                uint unpackSize    = LZMA2_UNPACK_SIZE_MAX;
                uint lzHeaderSize  = 5u + (mNeedInitProp ? 1u : 0u);

                packSizeRes = 0;
                if (packSize < lzHeaderSize)
                {
                    return(SZ_ERROR_OUTPUT_EOF);
                }
                packSize -= lzHeaderSize;

                mEnc.LzmaEnc_SaveState();
                SRes res = mEnc.LzmaEnc_CodeOneMemBlock(mNeedInitState, outBuf + lzHeaderSize, ref packSize, LZMA2_PACK_SIZE_MAX, ref unpackSize);

                TR("Lzma2EncInt_EncodeSubblock:packSize", checked ((int)packSize));
                TR("Lzma2EncInt_EncodeSubblock:unpackSize", unpackSize);
                DebugPrint("\npackSize = {0:0000000} unpackSize = {1:0000000}  ", packSize, unpackSize);

                if (unpackSize == 0)
                {
                    return(res);
                }

                bool useCopyBlock;

                if (res == SZ_OK)
                {
                    useCopyBlock = (packSize + 2 >= unpackSize || packSize > (1 << 16));
                }
                else
                {
                    if (res != SZ_ERROR_OUTPUT_EOF)
                    {
                        return(res);
                    }
                    res          = SZ_OK;
                    useCopyBlock = true;
                }

                if (useCopyBlock)
                {
                    long destPos = 0;
                    DebugPrint("################# COPY           ");

                    while (unpackSize > 0)
                    {
                        uint u = (unpackSize < LZMA2_COPY_CHUNK_SIZE) ? unpackSize : LZMA2_COPY_CHUNK_SIZE;
                        if (packSizeLimit - destPos < u + 3)
                        {
                            return(SZ_ERROR_OUTPUT_EOF);
                        }

                        outBuf[destPos++] = (byte)(mSrcPos == 0 ? LZMA2_CONTROL_COPY_RESET_DIC : LZMA2_CONTROL_COPY_NO_RESET);
                        outBuf[destPos++] = (byte)((u - 1) >> 8);
                        outBuf[destPos++] = (byte)(u - 1);

                        CUtils.memcpy(outBuf + destPos, mEnc.LzmaEnc_GetCurBuf() - unpackSize, u);

                        unpackSize -= u;
                        destPos    += u;
                        mSrcPos    += u;

                        if (outStream != null)
                        {
                            packSizeRes += destPos;
                            if (outStream.Write(outBuf, destPos) != destPos)
                            {
                                return(SZ_ERROR_WRITE);
                            }
                            destPos = 0;
                        }
                        else
                        {
                            packSizeRes = destPos;
                        }

                        /* needInitState = true; */
                    }

                    mEnc.LzmaEnc_RestoreState();
                    return(SZ_OK);
                }
                else
                {
                    long destPos = 0;
                    uint u       = unpackSize - 1;
                    uint pm      = (uint)(packSize - 1);

                    uint mode;
                    if (mSrcPos == 0)
                    {
                        mode = 3;
                    }
                    else if (!mNeedInitState)
                    {
                        mode = 0;
                    }
                    else if (!mNeedInitProp)
                    {
                        mode = 1;
                    }
                    else
                    {
                        mode = 2;
                    }

                    DebugPrint("               ");

                    outBuf[destPos++] = (byte)(LZMA2_CONTROL_LZMA | (mode << 5) | ((u >> 16) & 0x1F));
                    outBuf[destPos++] = (byte)(u >> 8);
                    outBuf[destPos++] = (byte)u;
                    outBuf[destPos++] = (byte)(pm >> 8);
                    outBuf[destPos++] = (byte)pm;

                    if (mNeedInitProp)
                    {
                        outBuf[destPos++] = mProps;
                    }

                    mNeedInitProp  = false;
                    mNeedInitState = false;
                    destPos       += packSize;
                    mSrcPos       += unpackSize;

                    if (outStream != null && outStream.Write(outBuf, destPos) != destPos)
                    {
                        return(SZ_ERROR_WRITE);
                    }

                    packSizeRes = destPos;
                    return(SZ_OK);
                }
            }
Esempio n. 14
0
            internal SRes MtCoder_Code()
            {
                int numThreads = mNumThreads;
                SRes res = SZ_OK;
                mRes = SZ_OK;

                mMtProgress.MtProgress_Init(mProgress);

                for(uint i = 0; i < numThreads; i++)
                {
                    if((res = mThreads[i].CMtThread_Prepare()) != SZ_OK)
                        return res;
                }

                for(uint i = 0; i < numThreads; i++)
                {
                    CMtThread t = mThreads[i];
                    CLoopThread lt = t.mThread;

                    if(!Thread_WasCreated(lt.mThread))
                    {
                        lt.mFunc = t.ThreadFunc;
                        if(lt.LoopThread_Create() != SZ_OK)
                        {
                            res = SZ_ERROR_THREAD;
                            break;
                        }
                    }
                }

                if(res == SZ_OK)
                {
                    int i;
                    for(i = 0; i < numThreads; i++)
                    {
                        CMtThread t = mThreads[i];
                        if(t.mThread.LoopThread_StartSubThread() != SZ_OK)
                        {
                            res = SZ_ERROR_THREAD;
                            Trace.MatchObjectWait(mThreads[0], "MtCoder_Code");
                            mThreads[0].mStopReading = true;
                            Trace.MatchObjectWait(mThreads[0], "MtCoder_Code");
                            break;
                        }
                    }

                    Event_Set(mThreads[0].mCanWrite);
                    Event_Set(mThreads[0].mCanRead);

                    for(int j = 0; j < i; j++)
                        mThreads[j].mThread.LoopThread_WaitSubThread();
                }

                for(uint i = 0; i < numThreads; i++)
                    mThreads[i].CMtThread_CloseEvents();

                return (res == SZ_OK) ? mRes : res;
            }
Esempio n. 15
0
            internal void RangeEnc_FlushStream()
            {
                if (mRes != SZ_OK)
                    return;

                long num = mBuf - mBufBase;
                if (num != mOutStream.Write(mBufBase, num))
                    mRes = SZ_ERROR_WRITE;

                mProcessed += (ulong)num;
                mBuf = mBufBase;
            }
Esempio n. 16
0
            internal SRes MtCoder_Code()
            {
                int  numThreads = mNumThreads;
                SRes res        = SZ_OK;

                mRes = SZ_OK;

                mMtProgress.MtProgress_Init(mProgress);

                for (uint i = 0; i < numThreads; i++)
                {
                    if ((res = mThreads[i].CMtThread_Prepare()) != SZ_OK)
                    {
                        return(res);
                    }
                }

                for (uint i = 0; i < numThreads; i++)
                {
                    CMtThread   t  = mThreads[i];
                    CLoopThread lt = t.mThread;

                    if (!Thread_WasCreated(lt.mThread))
                    {
                        lt.mFunc = t.ThreadFunc;
                        if (lt.LoopThread_Create() != SZ_OK)
                        {
                            res = SZ_ERROR_THREAD;
                            break;
                        }
                    }
                }

                if (res == SZ_OK)
                {
                    int i;
                    for (i = 0; i < numThreads; i++)
                    {
                        CMtThread t = mThreads[i];
                        if (t.mThread.LoopThread_StartSubThread() != SZ_OK)
                        {
                            res = SZ_ERROR_THREAD;
                            Trace.MatchObjectWait(mThreads[0], "MtCoder_Code");
                            mThreads[0].mStopReading = true;
                            Trace.MatchObjectWait(mThreads[0], "MtCoder_Code");
                            break;
                        }
                    }

                    Event_Set(mThreads[0].mCanWrite);
                    Event_Set(mThreads[0].mCanRead);

                    for (int j = 0; j < i; j++)
                    {
                        mThreads[j].mThread.LoopThread_WaitSubThread();
                    }
                }

                for (uint i = 0; i < numThreads; i++)
                {
                    mThreads[i].CMtThread_CloseEvents();
                }

                return((res == SZ_OK) ? mRes : res);
            }
Esempio n. 17
0
            internal void MatchFinder_Init()
            {
                //for(uint i = 0; i < mHashSizeSum; i++)
                //    mHash[i] = kEmptyHashValue;
                Array.Clear(mHash, 0, (int)mHashSizeSum);

                mCyclicBufferPos = 0;
                mBuffer = mBufferBase;
                mPos = mCyclicBufferSize;
                mStreamPos = mCyclicBufferSize;
                mResult = SZ_OK;
                mStreamEndWasReached = false;
                MatchFinder_ReadBlock();
                MatchFinder_SetLimits();
            }
Esempio n. 18
0
 internal void MtProgress_SetError(SRes res)
 {
     CriticalSection_Enter(mCS);
     if(mRes == SZ_OK)
         mRes = res;
     CriticalSection_Leave(mCS);
 }
Esempio n. 19
0
            internal void MtProgress_Init(ICompressProgress progress)
            {
                for(uint i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)
                    mInSizes[i] = mOutSizes[i] = 0;

                mTotalInSize = 0;
                mTotalOutSize = 0;
                mProgress = progress;
                mRes = SZ_OK;
            }
Esempio n. 20
0
 public SRes MtProgress_Set(int index, ulong inSize, ulong outSize)
 {
     CriticalSection_Enter(mCS);
     UPDATE_PROGRESS(inSize, ref mInSizes[index], ref mTotalInSize);
     UPDATE_PROGRESS(outSize, ref mOutSizes[index], ref mTotalOutSize);
     if(mRes == SZ_OK)
         mRes = Progress(mProgress, mTotalInSize, mTotalOutSize);
     SRes res = mRes;
     CriticalSection_Leave(mCS);
     return res;
 }
Esempio n. 21
0
            internal SRes LzmaEnc_CodeOneMemBlock(bool reInit, P<byte> dest, ref long destLen, uint desiredPackSize, ref uint unpackSize)
            {
                CSeqOutStreamBuf outStream = new CSeqOutStreamBuf();

                outStream.mData = dest;
                outStream.mRem = destLen;
                outStream.mOverflow = false;

                mWriteEndMark = false;
                mFinished = false;
                mResult = SZ_OK;

                if (reInit)
                    LzmaEnc_Init();

                LzmaEnc_InitPrices();
                ulong nowPos64 = mNowPos64;
                mRC.RangeEnc_Init();
                mRC.mOutStream = outStream;

                SRes res = LzmaEnc_CodeOneBlock(true, desiredPackSize, unpackSize);

                unpackSize = (uint)(mNowPos64 - nowPos64);
                destLen -= outStream.mRem;
                if (outStream.mOverflow)
                    return SZ_ERROR_OUTPUT_EOF;

                return res;
            }
Esempio n. 22
0
            internal void RangeEnc_Init()
            {
                /* Stream.Init(); */
                mLow = 0;
                mRange = 0xFFFFFFFF;
                mCacheSize = 1;
                mCache = 0;

                mBuf = mBufBase;

                mProcessed = 0;
                mRes = SZ_OK;
            }
Esempio n. 23
0
 public bool Equals(SRes obj)
 {
     return(obj._code == _code);
 }
Esempio n. 24
0
            /*
             * finishMode:
             * It has meaning only if the decoding reaches output limit (*destLen or dicLimit).
             * 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
             *    LZMA_STATUS_NEEDS_MORE_INPUT
             * SZ_ERROR_DATA - Data error
             */

            public SRes Lzma2Dec_DecodeToDic(long dicLimit, P <byte> src, ref long srcLen, ELzmaFinishMode finishMode, out ELzmaStatus status)
            {
                long inSize = srcLen;

                srcLen = 0;
                status = ELzmaStatus.LZMA_STATUS_NOT_SPECIFIED;

                while (mState != Lzma2State.Finished)
                {
                    long dicPos = mDecoder.mDicPos;
                    if (mState == Lzma2State.Error)
                    {
                        return(SZ_ERROR_DATA);
                    }

                    if (dicPos == dicLimit && finishMode == ELzmaFinishMode.LZMA_FINISH_ANY)
                    {
                        status = ELzmaStatus.LZMA_STATUS_NOT_FINISHED;
                        return(SZ_OK);
                    }

                    if (mState != Lzma2State.Data && mState != Lzma2State.DataCont)
                    {
                        if (srcLen == inSize)
                        {
                            status = ELzmaStatus.LZMA_STATUS_NEEDS_MORE_INPUT;
                            return(SZ_OK);
                        }
                        srcLen++;
                        mState = Lzma2Dec_UpdateState(src[0]);
                        src++;
                        continue;
                    }

                    long            destSizeCur   = dicLimit - dicPos;
                    long            srcSizeCur    = inSize - srcLen;
                    ELzmaFinishMode curFinishMode = ELzmaFinishMode.LZMA_FINISH_ANY;

                    if (mUnpackSize <= destSizeCur)
                    {
                        destSizeCur   = mUnpackSize;
                        curFinishMode = ELzmaFinishMode.LZMA_FINISH_END;
                    }

                    if (IsUncompressedState())
                    {
                        if (srcLen == inSize)
                        {
                            status = ELzmaStatus.LZMA_STATUS_NEEDS_MORE_INPUT;
                            return(SZ_OK);
                        }

                        if (mState == Lzma2State.Data)
                        {
                            bool initDic = (mControl == LZMA2_CONTROL_COPY_RESET_DIC);
                            if (initDic)
                            {
                                mNeedInitProp = mNeedInitState = true;
                            }
                            else if (mNeedInitDic)
                            {
                                return(SZ_ERROR_DATA);
                            }

                            mNeedInitDic = false;
                            mDecoder.LzmaDec_InitDicAndState(initDic, false);
                        }

                        if (srcSizeCur > destSizeCur)
                        {
                            srcSizeCur = destSizeCur;
                        }

                        if (srcSizeCur == 0)
                        {
                            return(SZ_ERROR_DATA);
                        }

                        LzmaDec_UpdateWithUncompressed(mDecoder, src, srcSizeCur);

                        src         += srcSizeCur;
                        srcLen      += srcSizeCur;
                        mUnpackSize -= (uint)srcSizeCur;
                        mState       = (mUnpackSize == 0) ? Lzma2State.Control : Lzma2State.DataCont;
                    }
                    else
                    {
                        long outSizeProcessed;

                        if (mState == Lzma2State.Data)
                        {
                            int  mode      = GetLzmaMode();
                            bool initDic   = (mode == 3);
                            bool initState = (mode > 0);
                            if ((!initDic && mNeedInitDic) || (!initState && mNeedInitState))
                            {
                                return(SZ_ERROR_DATA);
                            }

                            mDecoder.LzmaDec_InitDicAndState(initDic, initState);
                            mNeedInitDic   = false;
                            mNeedInitState = false;
                            mState         = Lzma2State.DataCont;
                        }

                        if (srcSizeCur > mPackSize)
                        {
                            srcSizeCur = mPackSize;
                        }

                        SRes res = mDecoder.LzmaDec_DecodeToDic(dicPos + destSizeCur, src, ref srcSizeCur, curFinishMode, out status);

                        src       += srcSizeCur;
                        srcLen    += srcSizeCur;
                        mPackSize -= (uint)srcSizeCur;

                        outSizeProcessed = mDecoder.mDicPos - dicPos;
                        mUnpackSize     -= (uint)outSizeProcessed;

                        if (res != SZ_OK)
                        {
                            return(res);
                        }

                        if (status == ELzmaStatus.LZMA_STATUS_NEEDS_MORE_INPUT)
                        {
                            return(res);
                        }

                        if (srcSizeCur == 0 && outSizeProcessed == 0)
                        {
                            if (status != ELzmaStatus.LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK || mUnpackSize != 0 || mPackSize != 0)
                            {
                                return(SZ_ERROR_DATA);
                            }

                            mState = Lzma2State.Control;
                        }

                        if (status == ELzmaStatus.LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK)
                        {
                            status = ELzmaStatus.LZMA_STATUS_NOT_FINISHED;
                        }
                    }
                }

                status = ELzmaStatus.LZMA_STATUS_FINISHED_WITH_MARK;
                return(SZ_OK);
            }
Esempio n. 25
0
    private UnityEngine.Object RegistResource(string path)
    {
        if (UnityTools.IsPackageResource(path))
            return null;
        UnityEngine.Object resObj = null;

        if (m_lResKeyList != null)
        {
            SRes iRes = m_lResKeyList.Find(SRes.MatchPath(path));
            if (iRes != null)
            {
                resObj = iRes.iResourceObject;
            }
            else
            {
                resObj = UnityResources.Load(path);
                if(null != resObj)
                {
                    iRes = new SRes(path, resObj);
                    m_lResKeyList.Add(iRes);
                }
            }

        }
        return resObj;
    }