1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-10-01 12:30:00 +02:00
Ryujinx/Ryujinx.HLE/FileSystem/SaveHelper.cs
emmauss fc77b089a6 Implements proper save path (#386)
* initial save path implementation

* fix savedatatype offset, remove incomplete createsavedata implimentation

* address nits

* fix crash if npdm is not found

* made saveinfo readonly, other stuff

* remove context param from saveinfo contructor

* fix style

* remove whitespace
2018-09-08 19:04:26 -03:00

46 lines
1.5 KiB
C#

using Ryujinx.HLE.HOS;
using System.IO;
using static Ryujinx.HLE.FileSystem.VirtualFileSystem;
namespace Ryujinx.HLE.FileSystem
{
static class SaveHelper
{
public static string GetSavePath(SaveInfo SaveMetaData, ServiceCtx Context)
{
string BaseSavePath = NandPath;
long CurrentTitleId = SaveMetaData.TitleId;
switch (SaveMetaData.SaveSpaceId)
{
case SaveSpaceId.NandUser:
BaseSavePath = UserNandPath;
break;
case SaveSpaceId.NandSystem:
BaseSavePath = SystemNandPath;
break;
case SaveSpaceId.SdCard:
BaseSavePath = Path.Combine(SdCardPath, "Nintendo");
break;
}
BaseSavePath = Path.Combine(BaseSavePath, "save");
if (SaveMetaData.TitleId == 0 && SaveMetaData.SaveDataType == SaveDataType.SaveData)
{
if (Context.Process.MetaData != null)
{
CurrentTitleId = Context.Process.MetaData.ACI0.TitleId;
}
}
string SavePath = Path.Combine(BaseSavePath,
SaveMetaData.SaveId.ToString("x16"),
SaveMetaData.UserId.ToString(),
SaveMetaData.SaveDataType == SaveDataType.SaveData ? CurrentTitleId.ToString("x16") : string.Empty);
return SavePath;
}
}
}