diff options
| author | Mary <1760003+Thog@users.noreply.github.com> | 2021-07-13 16:48:54 +0200 |
|---|---|---|
| committer | Mary <1760003+Thog@users.noreply.github.com> | 2021-07-13 16:48:54 +0200 |
| commit | 208ba1dde2b9a4d31446ace2bba8f0d641d2e300 (patch) | |
| tree | c7478e7eb87061400bab37daf4f2f69cf387d9f2 /Ryujinx.HLE/FileSystem/SaveHelper.cs | |
| parent | 997380d48cb3b74e2438cee7fc3b017d6b59b714 (diff) | |
Revert LibHac update
Users are facing save destruction on failing extra data update apparently
Diffstat (limited to 'Ryujinx.HLE/FileSystem/SaveHelper.cs')
| -rw-r--r-- | Ryujinx.HLE/FileSystem/SaveHelper.cs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Ryujinx.HLE/FileSystem/SaveHelper.cs b/Ryujinx.HLE/FileSystem/SaveHelper.cs new file mode 100644 index 00000000..51a25515 --- /dev/null +++ b/Ryujinx.HLE/FileSystem/SaveHelper.cs @@ -0,0 +1,45 @@ +using LibHac.Fs.Fsa; +using LibHac.FsSystem; +using Ryujinx.HLE.HOS; +using System.IO; + +namespace Ryujinx.HLE.FileSystem +{ + static class SaveHelper + { + public static IFileSystem OpenSystemSaveData(ServiceCtx context, ulong saveId) + { + SaveInfo saveInfo = new SaveInfo(0, (long)saveId, SaveDataType.SystemSaveData, SaveSpaceId.NandSystem); + string savePath = context.Device.FileSystem.GetSavePath(context, saveInfo, false); + + if (File.Exists(savePath)) + { + string tempDirectoryPath = $"{savePath}_temp"; + + Directory.CreateDirectory(tempDirectoryPath); + + IFileSystem outputFolder = new LocalFileSystem(tempDirectoryPath); + + using (LocalStorage systemSaveData = new LocalStorage(savePath, FileAccess.Read, FileMode.Open)) + { + IFileSystem saveFs = new LibHac.FsSystem.Save.SaveDataFileSystem(context.Device.System.KeySet, systemSaveData, IntegrityCheckLevel.None, false); + + saveFs.CopyDirectory(outputFolder, "/", "/"); + } + + File.Delete(savePath); + + Directory.Move(tempDirectoryPath, savePath); + } + else + { + if (!Directory.Exists(savePath)) + { + Directory.CreateDirectory(savePath); + } + } + + return new LocalFileSystem(savePath); + } + } +}
\ No newline at end of file |
