Пример #1
0
 public static void WritePpd(this DissipationFile file, string path)
 {
     using (var backup = new FileBackup(path))
         using (var writer = new StreamWriter(path))
         {
             writer.WritePpd(file);
             backup.Delete();
         }
 }
 private void SaveResults(List <ByteSearchResult <CharacterModel> > results)
 {
     lock (_lock)
     {
         var json = JsonConvert.SerializeObject(results,
                                                Formatting.Indented, new BaseGGUUIDConverter());
         using (var fb = new FileBackup(ResultsFile))
         {
             File.WriteAllText(ResultsFile, json);
             fb.Delete();
         }
     }
 }
Пример #3
0
        private bool CreatePatch()
        {
            //remove failed patches
            FileBackup.CleanupBackups(Configs.PatchPath);

            using (var oldPatch = new FileBackup(Configs.PatchPath))
            {
                var patcher = new Patcher();

                var patch = patcher.StartPatch();
                foreach (var module in Plugins)
                {
                    IoC.Notif.ShowStatus($"Generating patch ({module.PluginName})...");
                    module.ApplyChanges(patch);
                }

                IoC.Notif.ShowStatus("Generating plugin patches...");
                patcher.ApplyCustomPatches(patch, PluginManager);

                IoC.Notif.ShowStatus("Generating patch (rebuild prefetch)...");

                var p = Prefetch.Load(patch);
                if (p.Rebuild(patch))
                {
                    p.Save();
                }

                if (!Directory.Exists(patch.WorkingDir))
                {
                    IoC.Notif.ShowStatus("No changes found, aborting pack creation.");

                    return(false);
                }

                IoC.Notif.ShowStatus("Generating patch (packing)...");
                patcher.PackPatch(patch);

                IoC.Notif.ShowStatus("Copying patch...");
                patcher.InstallPatch(patch);

                oldPatch.Delete();

#if !DEBUG
                Paths.Cleanup(IoC.Config.TempPath);
#endif
            }

            return(true);
        }
Пример #4
0
        private static void Save(UserSettings settings)
        {
            try
            {
                _lock.Wait();

                Paths.CheckDirectory(ApplicationSettingsPath);

                using var backup = new FileBackup(SettingsPath);

                var json = JsonConvert.SerializeObject(settings, Formatting.Indented);
                File.WriteAllText(SettingsPath, json);

                backup.Delete();
            }
            finally
            {
                _lock.Release();
            }
        }