// 새로운 버전의 패치 정보를 추가 bool AddNewVersionPatchInfo(int NextVersion, List <PatchFileInfo> PatchFileInfoList) { // 다음 버전이 현재 패치정보파일의 마지막 버전보다 작으면 에러 // 다음 버전이 현재 패치정보파일의 마지막 버전보다 같으면 마지막 정보를 제거한다. int LastVersion = GetLastVersion(); if (LastVersion > NextVersion) { MessageBox.Show(string.Format("Invalid NextVersion {0}", NextVersion)); return(false); } else if (LastVersion == NextVersion) { PatchVersionInfoList.RemoveAt(PatchVersionInfoList.Count - 1); } PatchVersionInfo NewPatchInfo = new PatchVersionInfo(); NewPatchInfo.VersionNumber = NextVersion; foreach (PatchFileInfo fileinfo in PatchFileInfoList) { NewPatchInfo.Add(fileinfo.FileName, fileinfo.FileSize, fileinfo.FileCRC); } PatchVersionInfoList.Add(NewPatchInfo); return(true); }
// 패치정보 파일을 읽는다. bool ReadPatchInfoFile(string FullPathFileName) { bool bResult = false; PatchVersionInfoList.Clear(); if (false == File.Exists(FullPathFileName)) { //MessageBox.Show("have not file"); return(bResult); } try { StreamReader sr = File.OpenText(FullPathFileName); string JsonText = sr.ReadToEnd(); // http://james.newtonking.com/pages/json-net.aspx // http://james.newtonking.com/projects/json/help/LINQtoJSON.html JObject root = JObject.Parse(JsonText); JArray VersionList = (JArray)root["VERSION_LIST"]; foreach (JObject VersionInfo in VersionList) { PatchVersionInfo patchinfo = new PatchVersionInfo(); patchinfo.VersionNumber = (int)VersionInfo["Version"]; JArray FileInfos = (JArray)VersionInfo["Files"]; foreach (JObject fileInfo in FileInfos) { patchinfo.Add((string)fileInfo["filename"], (Int64)fileInfo["size"], (Int64)fileInfo["CRC"]); } PatchVersionInfoList.Add(patchinfo); } bResult = true; sr.Close(); } catch (Exception ex) { MessageBox.Show(string.Format("Failed Read PatchInfofile. file:{0}, Error:{1}", FullPathFileName, ex.ToString())); } return(bResult); }
public ShadersCredits() { InitializeComponent(); TextBlock.Text = PatchVersionInfo.ChangelogPrepare(File.ReadAllText(PatchHelper.TryGetConfigFilename("data_credits.txt") ?? string.Empty)); }
protected override ICopyCallback GetCopyCallback(string destination) { var path = EntryPath; var first = true; var cleanInstall = SelectedOption == CleanOption; var args = new CancelEventArgs(); InstallationStart?.Invoke(null, args); if (args.Cancel) { throw new InformativeException("Can’t install two things at once"); } var installedLogStream = new MemoryStream(); var installedLog = new StreamWriter(installedLogStream); IsBusy = true; return(new CopyCallback(info => { var filename = info.Key; if (path != string.Empty && !FileUtils.IsAffectedBy(filename, path) || !_toInstall.Contains(info.Key) && !_toInstall.Any(x => FileUtils.IsAffectedBy(info.Key, x))) { return null; } var relativePath = FileUtils.GetRelativePath(filename, path); var result = Path.Combine(InstallTo(), relativePath); if (first) { var directory = Path.Combine(InstallTo(), PatchDirectoryName); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } else if (cleanInstall) { PatchVersionInfo.RemovePatch(false).Wait(); } FileUtils.TryToDelete(PatchHelper.GetInstalledLog()); FileUtils.TryToDelete(Path.Combine(PatchHelper.GetRootDirectory(), "config", "data_manifest.ini")); first = false; installedLog.WriteLine(@"# Generated automatically during last patch installation via Content Manager."); installedLog.WriteLine(@"# Do not edit, unless have to for some reason."); installedLog.WriteLine(@"# This particular log was generated during custom ZIP-file installation."); installedLog.WriteLine(@"version: 0"); installedLog.WriteLine(@"build: 0"); } installedLog.WriteLine($@"file: {relativePath}:0:0:0"); return result; }, dispose: () => { installedLog.Dispose(); File.WriteAllBytes(PatchHelper.GetInstalledLog(), installedLogStream.ToArray()); installedLogStream.Dispose(); InstallationEnd?.Invoke(null, EventArgs.Empty); IsBusy = false; PatchHelper.Reload(); if (PatchUpdater.Instance != null) { PatchUpdater.Instance.ForceVersion.Value = true; } })); }