mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-24 12:04:15 +00:00
1ff89d6482
* Implement basic support of SystemSaveData and Cleanup IFileSystemProxy - Implement `OpenSystemSaveData` as a `IFileSystem` in `SaveHelper`: On real device, system saves data are stored encrypted, and we can't create an empty system save data for now. That's why if a user put his own dump of system save in `RyuFs\nand\system\save\`, we extract content in associated folder and open it as a `IFileSystem`. If the system save data don't exist, a folder is created. - Cleanup `IFileSystemProxy` by adding a Helper class. - Implement `GetSavePath` in `VirtualFileSystem` and remove `GetGameSavePath` in `SaveHelper`. * remove the forgotten I * Fix align
44 lines
No EOL
1.4 KiB
C#
44 lines
No EOL
1.4 KiB
C#
using LibHac.Fs;
|
|
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.Fs.Save.SaveDataFileSystem(context.Device.System.KeySet, systemSaveData, IntegrityCheckLevel.None, false);
|
|
|
|
saveFs.CopyFileSystem(outputFolder);
|
|
}
|
|
|
|
File.Delete(savePath);
|
|
|
|
Directory.Move(tempDirectoryPath, savePath);
|
|
}
|
|
else
|
|
{
|
|
if (!Directory.Exists(savePath))
|
|
{
|
|
Directory.CreateDirectory(savePath);
|
|
}
|
|
}
|
|
|
|
return new LocalFileSystem(savePath);
|
|
}
|
|
}
|
|
} |