2018-09-08 18:04:26 -04:00
|
|
|
|
using Ryujinx.HLE.HOS;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
using static Ryujinx.HLE.FileSystem.VirtualFileSystem;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.FileSystem
|
|
|
|
|
{
|
|
|
|
|
static class SaveHelper
|
|
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
|
public static string GetSavePath(SaveInfo saveMetaData, ServiceCtx context)
|
2018-09-08 18:04:26 -04:00
|
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
|
string baseSavePath = NandPath;
|
2019-09-02 12:03:57 -04:00
|
|
|
|
ulong currentTitleId = saveMetaData.TitleId;
|
2018-09-08 18:04:26 -04:00
|
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
|
switch (saveMetaData.SaveSpaceId)
|
2018-09-08 18:04:26 -04:00
|
|
|
|
{
|
|
|
|
|
case SaveSpaceId.NandUser:
|
2018-12-06 06:16:24 -05:00
|
|
|
|
baseSavePath = UserNandPath;
|
2018-09-08 18:04:26 -04:00
|
|
|
|
break;
|
|
|
|
|
case SaveSpaceId.NandSystem:
|
2018-12-06 06:16:24 -05:00
|
|
|
|
baseSavePath = SystemNandPath;
|
2018-09-08 18:04:26 -04:00
|
|
|
|
break;
|
|
|
|
|
case SaveSpaceId.SdCard:
|
2018-12-06 06:16:24 -05:00
|
|
|
|
baseSavePath = Path.Combine(SdCardPath, "Nintendo");
|
2018-09-08 18:04:26 -04:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
|
baseSavePath = Path.Combine(baseSavePath, "save");
|
2018-09-08 18:04:26 -04:00
|
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
|
if (saveMetaData.TitleId == 0 && saveMetaData.SaveDataType == SaveDataType.SaveData)
|
2018-09-08 18:04:26 -04:00
|
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
|
currentTitleId = context.Process.TitleId;
|
2018-09-08 18:04:26 -04:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-04 11:14:17 -04:00
|
|
|
|
string saveAccount = saveMetaData.UserId.IsNull ? "savecommon" : saveMetaData.UserId.ToString();
|
2018-10-07 09:13:46 -04:00
|
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
|
string savePath = Path.Combine(baseSavePath,
|
|
|
|
|
saveMetaData.SaveId.ToString("x16"),
|
|
|
|
|
saveAccount,
|
|
|
|
|
saveMetaData.SaveDataType == SaveDataType.SaveData ? currentTitleId.ToString("x16") : string.Empty);
|
2018-09-08 18:04:26 -04:00
|
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
|
return savePath;
|
2018-09-08 18:04:26 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|