private static void CompressSingleFile(string path, string outputPath) { JObject obj = JsonConvert.DeserializeObject <JObject>(File.ReadAllText(path)); Compress(obj); var result = new SaveDataProxy { m_BaseName = obj["m_BaseName"], m_DisplayName = obj["m_DisplayName"], m_Episode = obj["m_Episode"], m_GameId = obj["m_GameId"], m_GameMode = obj["m_GameMode"], m_IsPS4Compliant = obj["m_IsPS4Compliant"], m_Name = obj["m_Name"], m_Timestamp = obj["m_Timestamp"], m_Dict = new Dictionary <string, byte[]>() }; var dict = (JObject)obj["m_Dict"]; foreach (var jo in dict) { var fileJson = JsonConvert.SerializeObject(jo.Value, Formatting.None); fileJson = Util.ShittifyJson(fileJson); result.m_Dict[jo.Key.ToString()] = CLZF.Compress(Encoding.UTF8.GetBytes(fileJson)); jo.Value.Replace(null); } var resultJson = JsonConvert.SerializeObject(result, Formatting.None); File.WriteAllBytes(outputPath, CLZF.Compress(Encoding.UTF8.GetBytes(resultJson))); }
private static byte[] ReadJToken(string path) { JToken token = JToken.Parse(File.ReadAllText(path)); Compress(token); var fileJson = JsonConvert.SerializeObject(token, Formatting.None); var json = Util.ShittifyJson(fileJson); return(CLZF.Compress(Encoding.UTF8.GetBytes(json))); }
private static void CompressMultipleFiles(string path, string outputPath) { string scenesPath = Path.Combine(path, "scenes"); string slotDataPath = Path.Combine(path, "slotData.json"); SaveDataProxy slot = JsonConvert.DeserializeObject <SaveDataProxy>(File.ReadAllText(slotDataPath)); slot.m_Dict["global"] = ReadJToken(Path.Combine(path, "global.json")); slot.m_Dict["boot"] = ReadJToken(Path.Combine(path, "boot.json")); slot.m_Dict["screenshot"] = ReadJToken(Path.Combine(path, "screenshot.json")); foreach (var file in Directory.GetFiles(scenesPath)) { slot.m_Dict[Path.GetFileNameWithoutExtension(file)] = ReadJToken(file); } var resultJson = JsonConvert.SerializeObject(slot, Formatting.None); File.WriteAllBytes(outputPath, CLZF.Compress(Encoding.UTF8.GetBytes(resultJson))); }