示例#1
0
        // 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));
        }
示例#2
0
        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);
            }
        }