mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-24 18:11:21 -08:00
8a8ea4c8c0
* Update to LibHac 0.6.0 * Create an IFileSystemProxy object from LibHac * Rename rc -> result * Alignment and spacing * Result formatting * Spacing * Sort usings
45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using LibHac.Fs;
|
|
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);
|
|
}
|
|
}
|
|
} |