public void UnInit()
 {
     StopAllCoroutines();
     //
     _curSession    = null;
     _localFileList = null;
     _netFileList   = null;
     _diffFileList  = null;
     //移动解压终止
     if (_cachedDownloader != null)
     {
         _cachedDownloader.Dispose();
         _cachedDownloader = null;
     }
     //终止文件列表下载
     if (_diffDownloadInfo != null)
     {
         foreach (KeyValuePair <uint, string> kvp in _diffDownloadInfo)
         {
             HttpService.GetInstance().UnRegisteFileHttpDownload(kvp.Key);
         }
         _diffDownloadInfo.Clear();
         _diffDownloadInfo = null;
     }
     _errorCnt = 0;
     IsDone    = false;
 }
        public void StopSession()
        {
            StopCoroutine("StartSession");
            //回收
            if (_netFileList != null)
            {
                _netFileList = null;
            }
            if (_localFileList != null)
            {
                _localFileList = null;
            }
            if (_diffFileList != null)
            {
                _diffFileList = null;
            }

            //移动解压终止
            if (_cachedDownloader != null)
            {
                _cachedDownloader.Dispose();
                _cachedDownloader = null;
            }
            //终止文件列表下载
            if (_diffDownloadInfo != null)
            {
                foreach (KeyValuePair <uint, string> kvp in _diffDownloadInfo)
                {
                    HttpService.GetInstance().UnRegisteFileHttpDownload(kvp.Key);
                }
                _diffDownloadInfo.Clear();
                _diffDownloadInfo = null;
            }

            if (_curSession == null)
            {
                JW.Common.Log.LogE("IFS Service Stop No Run");
                return;
            }
            else
            {
                _curSession.SessionHandler = null;
                //删除标记文件
                string ifsDir    = JW.Res.FileUtil.GetIFSExtractPath();
                string localPath = JW.Res.FileUtil.CombinePath(ifsDir, _curSession.FileListFileName);
                JW.Res.FileUtil.DeleteFile(localPath);
                _curSession = null;
            }
            //
            IsDone = true;
        }
        //首次移动或者下载
        IEnumerator DoFirstMoveOrDownload()
        {
            bool isNeedMove = false;

            if (!JW.Res.FileUtil.IsExistInIFSExtraFolder(_curSession.FileListFileName))
            {
                isNeedMove = true;
            }
            //--------------------移动或者下载--------
            if (isNeedMove)
            {
                string filePath   = "";
                bool   isDownload = false;
                //存在
                if (JW.Res.FileUtil.IsFileExistInStreamingAssets(_curSession.FirstZipName))
                {
                    CallSessionHandler(IFSState.FirstMoveInit, 0);
                    filePath = JW.Res.FileUtil.GetStreamingAssetsPathWithHeader(_curSession.FirstZipName);
                }
                else
                {
                    isDownload = true;
                    filePath   = _curSession.FirstZipURL;
                    CallSessionHandler(IFSState.FirstDownloadInit, 0);
                }
                JW.Common.Log.LogD("DoFirstMoveOrDownload:" + filePath);
                yield return(null);

                if (!string.IsNullOrEmpty(filePath))
                {
                    string ifsDirPath = JW.Res.FileUtil.GetIFSExtractPath();
                    if (!JW.Res.FileUtil.IsDirectoryExist(ifsDirPath))
                    {
                        JW.Common.Log.LogD("Create IFS Dir " + ifsDirPath);
                        JW.Res.FileUtil.CreateDirectory(ifsDirPath);
                    }
                    //非android 直接解压
                    if (false)//isDownload==false && (Application.platform== RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.WindowsPlayer|| Application.platform == RuntimePlatform.WindowsEditor))
                    {
                        CallSessionHandler(IFSState.FirstUnZip, 0f);
                        string pp = JW.Res.FileUtil.GetStreamingAssetsPath(_curSession.FirstZipName);
                        IFSArchiver.SyncUnarchiveIFSFile(pp, ifsDirPath, false);
                        CallSessionHandler(IFSState.FirstUnZip, 1f);
                    }
                    else
                    {
                        //边下载边解档
                        IFSFileDownloader www = new IFSFileDownloader(filePath, ifsDirPath);
                        _cachedDownloader = www;
                        //
                        CallSessionHandler(isDownload ? IFSState.FirstDownloading : IFSState.FirstMoving, 0);
                        //
                        www.Begin();
                        while (www.IsDone == false)
                        {
                            www.Update();
                            CallSessionHandler(isDownload ? IFSState.FirstDownloading : IFSState.FirstMoving, www.Progress);
                            yield return(null);
                        }
                        if (www.IsError == false)
                        {
                            CallSessionHandler(isDownload ? IFSState.FirstDownloading : IFSState.FirstMoving, 1.0f);
                            yield return(null);

                            CallSessionHandler(IFSState.FirstUnZip, 0f);
                            yield return(null);

                            CallSessionHandler(IFSState.FirstUnZip, 1.0f);
                        }
                        else
                        {
                            JW.Common.Log.LogE("IFSService DoFirstMoveOrDownload Error");
                            _errorCnt++;
                            CallSessionHandler(isDownload ? IFSState.FirstDownloadFailed : IFSState.FirstMoveFailed, 1.0f);
                        }
                        www.Dispose();
                        www = null;
                        _cachedDownloader = null;
                    }
                }
                else
                {
                    JW.Common.Log.LogE("IFSService DoFirstMoveOrDownload Error FilePATH");
                    CallSessionHandler(isDownload ? IFSState.FirstDownloadFailed : IFSState.FirstMoveFailed, 1.0f);
                }
            }
            else
            {
                JW.Common.Log.LogD("No Need Move!");
            }
            yield return(null);
        }