// TODO: Move all save file handling into a separate class private object ReadLatestSaveFile(GameSaveDir gsd, GameModes gameMode) { string metadataPath; string storagePath; uint archiveNumber; ulong? profileKey; gsd.FindLatestGameSaveFiles(gameMode, out metadataPath, out storagePath, out archiveNumber, out profileKey); LogVerbose("Reading latest {0}-mode save game file from:\n {1}", gameMode, storagePath); string jsonStr = Storage.Read(metadataPath, storagePath, archiveNumber, profileKey); return(JsonConvert.DeserializeObject(jsonStr)); }
private void WriteLatestSaveFile(GameSaveDir gsd, GameModes gameMode, object json, bool useOldFormat) { string formattedJson = JsonConvert.SerializeObject(json, Formatting.None); string metadataPath; string storagePath; uint archiveNumber; ulong? profileKey; gsd.FindLatestGameSaveFiles(gameMode, out metadataPath, out storagePath, out archiveNumber, out profileKey); LogVerbose("Writing latest {0}-mode save game file to:\n {1}", gameMode, storagePath); using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(formattedJson))) { Storage.Write(metadataPath, storagePath, ms, archiveNumber, profileKey, useOldFormat); var now = DateTime.Now; File.SetLastWriteTime(metadataPath, now); File.SetLastWriteTime(storagePath, now); } }