Пример #1
0
    private void UnFoldUpkThread(object p)
    {
        UPKData param  = p as UPKData;
        string  tarDir = Path.GetDirectoryName(param.tarPath);

        string md5 = Util.Instance.SimpleMD5CryptoServiceProvider(param.data);

        if (!param.tarPath.Contains(md5))
        {
            string tmd5 = Util.Instance.SimpleMD5CryptoServiceProvider(param.data);
            Debug.LogError(param.tarPath + "!=md5:" + md5);
            param.cb(UPK_LOADED_STATE.MD5_ERR);
            return;
        }
        if (!Directory.Exists(tarDir))
        {
            Directory.CreateDirectory(tarDir);
        }
        //     try
        //     {
        //SevenZipHelper.Instance.DecompressFileLZMA(param.data,param.tarPath);
        //if(!Directory.Exists(param.tarDir))Directory.CreateDirectory(param.tarDir);
        //UPKHelper.Instance.UnPackFolder(param.tarPath,param.tarDir);
        //}
        //catch(System.Exception e)
        //{
        //    Debug.Log("some exception occured: " + e.Message);
        //    param.cb(UPK_LOADED_STATE.MD5_ERR);
        //    return;
        //}
        //finally
        //{
        //    if(File.Exists(param.tarPath))
        //    {
        //        File.Delete(param.tarPath);
        //    }
        //}
        param.cb(UPK_LOADED_STATE.SUC);
        lock (endThreadList)
        {
            endThreadList.Add(param.key);
        }
    }
Пример #2
0
    public bool WriteUpk(DownLoadUnit dlu, string key, UpkLoadedCallBack cb)
    {
        if (!Application.temporaryCachePath.Equals(""))
        {
            UPKData bd = new UPKData();

            bd.data = dlu.GetWWW().bytes;
            if (bd.data != null && bd.data.Length > 0)
            {
                bd.tarDir  = GameInfo.FilePath;
                bd.tarPath = GameInfo.FilePath + dlu.mReq.mUrl.Replace(".unity3d", ".txt");
                bd.key     = key;
                bd.cb      = cb;
                upkQueue.Enqueue(bd);
                ProcessManager.Add(this);
                return(true);
            }
        }
        return(false);
    }
Пример #3
0
    public void Update(float deltaTime)
    {
        lock (endThreadList)
        {
            if (endThreadList.Count > 0)
            {
                for (int i = 0; i < endThreadList.Count; i++)
                {
                    ThreadMgr.Instance.End(endThreadList[i]);
                    workingThreadList.Remove(endThreadList[i]);
                }
                endThreadList.Clear();
            }
        }

        if (upkQueue.Count > 0 && workingThreadList.Count <= MaxThreadCount)
        {
            UPKData data = upkQueue.Dequeue();
            workingThreadList.Add(data.key);
            ThreadMgr.Instance.Start(data.key, new System.Threading.Thread(new  System.Threading.ParameterizedThreadStart(UnFoldUpkThread)), data as object);
        }
    }