public async UniTask <uint> LoadFile(Context context, string path, uint baseAddress = 0) { await FileSystem.PrepareFile(context.BasePath + path); if (!FileSystem.FileExists(context.BasePath + path)) { return(0); } if (baseAddress != 0) { PS1MemoryMappedFile file = new PS1MemoryMappedFile(context, baseAddress, InvalidPointerMode) { filePath = path, Endianness = BinaryFile.Endian.Big }; context.AddFile(file); return(file.Length); } else { LinearSerializedFile file = new LinearSerializedFile(context) { filePath = path, Endianness = BinaryFile.Endian.Big }; context.AddFile(file); return(0); } }
public async UniTask <uint> LoadFile(Context context, string path, uint baseAddress) { await FileSystem.PrepareFile(context.BasePath + path); if (baseAddress != 0) { PS1MemoryMappedFile file = new PS1MemoryMappedFile(context, baseAddress, InvalidPointerMode) { filePath = path, Length = FileSizes[path] }; context.AddFile(file); return(FileSizes[path]); } else { LinearSerializedFile file = new LinearSerializedFile(context) { filePath = path, length = FileSizes.ContainsKey(path) ? FileSizes[path] : 0 }; context.AddFile(file); return(0); } }
public void DecryptSaveFiles(GameSettings settings) { using (var context = new Context(settings)) { foreach (var save in Directory.GetFiles(settings.GameDirectory, "*.sav", SearchOption.TopDirectoryOnly).Select(Path.GetFileName)) { LinearSerializedFile f = new LinearSerializedFile(context) { filePath = save }; context.AddFile(f); SerializerObject s = context.Deserializer; byte[] saveData = null; s.DoAt(f.StartPointer, () => { s.DoEncoded(new PC_R1_SaveEncoder(), () => { saveData = s.SerializeArray <byte>(saveData, s.CurrentLength, name: "SaveData"); Util.ByteArrayToFile(context.BasePath + save + ".dec", saveData); }); }); /*LinearSerializedFile f2 = new LinearSerializedFile(context) { * filePath = save + ".recompressed" * }; * context.AddFile(f2); * s = context.Serializer; * s.DoAt(f2.StartPointer, () => { * s.DoEncoded(new R1PCSaveEncoder(), () => { * saveData = s.SerializeArray<byte>(saveData, saveData.Length, name: "SaveData"); * }); * });*/ } } }
public void ReadSaveFiles(GameSettings settings) { using (var context = new Context(settings)) { foreach (var save in Directory.GetFiles(settings.GameDirectory, "*.sav", SearchOption.TopDirectoryOnly).Select(Path.GetFileName)) { LinearSerializedFile f = new LinearSerializedFile(context) { filePath = save }; context.AddFile(f); SerializerObject s = context.Deserializer; s.DoAt(f.StartPointer, () => { s.DoEncoded(new PC_R1_SaveEncoder(), () => s.SerializeObject <R1_PC_SaveFile>(default, name: "SaveFile"));
public static async UniTask <LinearSerializedFile> AddLinearSerializedFileAsync(this Context context, string filePath, BinaryFile.Endian endianness = BinaryFile.Endian.Little, bool recreateOnWrite = true) { await FileSystem.PrepareFile(context.BasePath + filePath); if (!FileSystem.FileExists(context.BasePath + filePath)) { return(null); } var file = new LinearSerializedFile(context) { filePath = filePath, Endianness = endianness, RecreateOnWrite = recreateOnWrite }; context.AddFile(file); return(file); }