private void EnterNextState() { if (mLocalFileListHasChange) { string fileOpeError = string.Empty; FileErrorCode result = FileOperateUtils.TryFileWrite(delegate() { string fileContent = FileListUtils.FileListToString(mSynchronizeData.persistentFileListDic); string relativePath = FileSystemUtils.GetFileRelativePath(FileDownloadData.FileListFileName, string.Empty); GameMain.Instance.FileOperateMgr.WriteTextFile(relativePath, fileContent, false); }, out fileOpeError); if (FileErrorCode.Null != result) { mErrorHandler.Invoke(result, "Write filelist"); return; } } if (mSynchronizeData.needDownloadSet.Count > 0) { mNextHandler.Invoke(FileDownloadStateId.DownLoadFile); } else { mNextHandler.Invoke(FileDownloadStateId.WritePersistentVersionFile); } }
/// <summary> /// 把文件列表和Version信息同步到硬盘 /// </summary> private void SyncInfoToHardDisk() { string fileOpeError = string.Empty; string fileListMd5 = string.Empty; //同步Version信息 FileErrorCode result = FileOperateUtils.TryFileWrite(delegate() { string fileContent = FileListUtils.FileListToString(mSynchronizeData.persistentFileListDic); fileListMd5 = Utils.MD5(fileContent); string relativePath = FileSystemUtils.GetFileRelativePath(FileDownloadData.FileListFileName, string.Empty); GameMain.Instance.FileOperateMgr.WriteTextFile(relativePath, fileContent, false); }, out fileOpeError); //同步文件列表信息 if (FileErrorCode.Null == result) { mSynchronizeData.localVersionInfo.persistentMd5 = fileListMd5; result = FileOperateUtils.TryFileWrite(delegate() { string fileContent = Newtonsoft.Json.JsonConvert.SerializeObject(mSynchronizeData.localVersionInfo); string relativePath = FileSystemUtils.GetFileRelativePath(FileDownloadData.VersionFileName, string.Empty); GameMain.Instance.FileOperateMgr.WriteTextFile(relativePath, fileContent, false); }, out fileOpeError); if (FileErrorCode.Null == result) { mHdlNextState.Invoke(FileDownloadStateId.LoadStreamingFileList); } else { mHdlError.Invoke(result, "Version info"); } } else { mHdlError.Invoke(result, "FileList info"); } }