public bool RunEncrypt(EncryptOptions opt) { DoCommon(opt); GameSaveDir gsd; try { gsd = new GameSaveDir(opt.SaveDir); } catch (Exception x) { LogError("Error locating game save file:\n{0}", x.Message); return(false); } LogVerbose("Reading JSON save game data from: {0}", opt.InputPath); string unformattedJson; try { unformattedJson = File.ReadAllText(opt.InputPath); } catch (IOException x) { LogError("Error reading JSON save game file: {0}", x.Message); return(false); } LogVerbose("Validating (parsing) JSON save game data"); object json; try { json = JsonConvert.DeserializeObject(unformattedJson); } catch (Exception x) { LogError("Error parsing save game file: {0}", x.Message); return(false); } BackupSave(gsd, opt); try { WriteLatestSaveFile(gsd, opt.GameMode, json, opt.UseOldFormat); } catch (Exception x) { LogError("Error storing save file: {0}", x.Message); return(false); } return(true); }
private void RunEncrypt(EncryptOptions opt) { DoGameSlotCommon(opt); LogVerbose("Loading JSON save game data from: {0}", opt.InputPath); try { _gs = _gsm.ReadUnencryptedGameSave(opt.InputPath); } catch (Exception x) { throw new Exception(string.Format("Error reading or parsing save game file: {0}", x.Message)); } if (opt.BackupDir != null) { try { BackupSave(opt.BackupDir, opt.FullBackup); } catch (Exception x) { throw new Exception(string.Format("Error backing up save game: {0}", x.Message)); } } try { _gsm.WriteSaveFile(_gs, _gameSlot); } catch (Exception x) { throw new Exception(string.Format("Error storing save file: {0}", x.Message)); } Log("Encrypted game save file \"{0}\" and wrote to latest game save for game slot {1}", opt.InputPath, _gameSlot); }