static void MD5Res() { string path = PathManager.RES_LOCAL_ROOT_PATH + "/" + PathManager.GetEditorPlatform(); string[] files = Directory.GetFiles(path, "*", SearchOption.AllDirectories); StringBuilder sb = new StringBuilder(); VersionRes version = new VersionRes(); version.version = "1.00"; version.resList = new List <VersionResData>(); for (int i = 0; i < files.Length; i++) { VersionResData resData = new VersionResData(); resData.resLength = FileUtility.GetFileLength(files[i]); resData.resMD5 = FileUtility.MD5File(files[i]); resData.resName = files[i].Replace("\\", "/").Replace(path + "/", ""); if (resData.resName != "VersionRes.txt") { version.resList.Add(resData); } //sb.AppendLine(string.Format("{0}|{1}|{2}", files[i].Replace("\\", "/").Replace(path + "/", ""), hash, fs.Length)); } string versionJson = JsonUtility.ToJson(version); FileStream md5FS = File.Open(path + "/VersionRes.txt", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); StreamWriter sw = new StreamWriter(md5FS); sw.Write(versionJson); sw.Close(); md5FS.Close(); md5FS.Dispose(); Debug.Log("生成MD5成功!"); }
/// <summary> /// The GetProjectById /// </summary> /// <param name="id">The id<see cref="string"/></param> /// <returns>The <see cref="Task{List{ProjectManagement.Models.Project}}"/></returns> public async Task <List <ProjectManagement.Models.Version> > GetVersionAsync(string id) { string url = string.Format("{0}/{1}/versions", Route.UserProjects, id); RestRequest req = new RestRequest(url, Method.GET); req.AddHeader("Content-Type", "application/json"); req.AddHeader("Authorization", "Bearer " + AuthProvider.Instance.token.token); Task <IRestResponse> resTask = Route.Client.ExecuteTaskAsync(req); var res = await resTask; VersionRes Version = JsonConvert.DeserializeObject <VersionRes>(res.Content); return(Version.data[0].versions); }
private static void GeneratorDiff() { StringBuilder result = new StringBuilder(); string path1 = mDiffResPath1 + "/VersionRes.txt"; string path2 = mDiffResPath2 + "/VersionRes.txt"; if (!File.Exists(path1) || !File.Exists(path2)) { Debug.LogError("GeneratorDiff 找不到目标文件"); return; } string content1 = File.ReadAllText(path1); string content2 = File.ReadAllText(path2); VersionRes data1 = JsonUtility.FromJson <VersionRes>(content1); VersionRes data2 = JsonUtility.FromJson <VersionRes>(content2); ReadAllHistory(mOutputHistoryPath); string templateStr = "<file path=\"{0}\" opt=\"{1}\" size=\"{2}\"/>"; result.AppendLine("<root>"); for (int i = 0; i < data1.resList.Count; i++) { VersionResData sourceData = data1.resList[i]; VersionResData targetData = data2.resList.Find((VersionResData resData) => { if (resData.resName == sourceData.resName) { return(true); } return(false); }); if (targetData != null) { if (sourceData.resMD5 != targetData.resMD5) { result.AppendLine(string.Format(templateStr, targetData.resName, GetHistory(targetData.resName, "update"), targetData.resLength)); FileCopyToDir(targetData.resName, mDiffResPath2, mOutputDiffPath); } } else { result.AppendLine(string.Format(templateStr, sourceData.resName, GetHistory(sourceData.resName, "delete"), sourceData.resLength)); } } for (int i = 0; i < data2.resList.Count; i++) { VersionResData sourceData = data2.resList[i]; VersionResData targetData = data1.resList.Find((VersionResData resData) => { if (resData.resName == sourceData.resName) { return(true); } return(false); }); if (targetData == null) { result.AppendLine(string.Format(templateStr, sourceData.resName, GetHistory(sourceData.resName, "add"), sourceData.resLength)); FileCopyToDir(sourceData.resName, mDiffResPath2, mOutputDiffPath); } } result.AppendLine("</root>"); FileStream fs = File.Open(mOutputDiffPath + "/filemanifest.xml", FileMode.Create, FileAccess.ReadWrite); StreamWriter wr = new StreamWriter(fs); wr.Write(result); wr.Close(); fs.Close(); SaveAllHistory(mOutputHistoryPath); //ZipUtility.ZipFileFromDirectory(mOutputDiffPath, mOutputDiffPath + ".zip", 4); //ZipUtil.ExeCompOne(mOutputDiffPath, mOutputDiffPath + ".zip"); Debug.Log("############Finish"); }