2018-11-18 19:37:41 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
using static Ryujinx.HLE.FileSystem.VirtualFileSystem;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.FileSystem.Content
|
|
|
|
|
{
|
|
|
|
|
internal static class LocationHelper
|
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
public static string GetRealPath(VirtualFileSystem FileSystem, string SwitchContentPath)
|
2018-11-18 19:37:41 +00:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
string BasePath = FileSystem.GetBasePath();
|
2018-11-18 19:37:41 +00:00
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
switch (SwitchContentPath)
|
2018-11-18 19:37:41 +00:00
|
|
|
|
{
|
|
|
|
|
case ContentPath.SystemContent:
|
2018-12-05 00:52:39 +00:00
|
|
|
|
return Path.Combine(FileSystem.GetBasePath(), SystemNandPath, "Contents");
|
2018-11-18 19:37:41 +00:00
|
|
|
|
case ContentPath.UserContent:
|
2018-12-05 00:52:39 +00:00
|
|
|
|
return Path.Combine(FileSystem.GetBasePath(), UserNandPath, "Contents");
|
2018-11-18 19:37:41 +00:00
|
|
|
|
case ContentPath.SdCardContent:
|
2018-12-05 00:52:39 +00:00
|
|
|
|
return Path.Combine(FileSystem.GetSdCardPath(), "Nintendo", "Contents");
|
2018-11-18 19:37:41 +00:00
|
|
|
|
case ContentPath.System:
|
2018-12-05 00:52:39 +00:00
|
|
|
|
return Path.Combine(BasePath, SystemNandPath);
|
2018-11-18 19:37:41 +00:00
|
|
|
|
case ContentPath.User:
|
2018-12-05 00:52:39 +00:00
|
|
|
|
return Path.Combine(BasePath, UserNandPath);
|
2018-11-18 19:37:41 +00:00
|
|
|
|
default:
|
2018-12-05 00:52:39 +00:00
|
|
|
|
throw new NotSupportedException($"Content Path `{SwitchContentPath}` is not supported.");
|
2018-11-18 19:37:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
public static string GetContentPath(ContentStorageId ContentStorageId)
|
2018-11-18 19:37:41 +00:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
switch (ContentStorageId)
|
2018-11-18 19:37:41 +00:00
|
|
|
|
{
|
|
|
|
|
case ContentStorageId.NandSystem:
|
|
|
|
|
return ContentPath.SystemContent;
|
|
|
|
|
case ContentStorageId.NandUser:
|
|
|
|
|
return ContentPath.UserContent;
|
|
|
|
|
case ContentStorageId.SdCard:
|
|
|
|
|
return ContentPath.SdCardContent;
|
|
|
|
|
default:
|
2018-12-05 00:52:39 +00:00
|
|
|
|
throw new NotSupportedException($"Content Storage `{ContentStorageId}` is not supported.");
|
2018-11-18 19:37:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
public static string GetContentRoot(StorageId StorageId)
|
2018-11-18 19:37:41 +00:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
switch (StorageId)
|
2018-11-18 19:37:41 +00:00
|
|
|
|
{
|
|
|
|
|
case StorageId.NandSystem:
|
|
|
|
|
return ContentPath.SystemContent;
|
|
|
|
|
case StorageId.NandUser:
|
|
|
|
|
return ContentPath.UserContent;
|
|
|
|
|
case StorageId.SdCard:
|
|
|
|
|
return ContentPath.SdCardContent;
|
|
|
|
|
default:
|
2018-12-05 00:52:39 +00:00
|
|
|
|
throw new NotSupportedException($"Storage Id `{StorageId}` is not supported.");
|
2018-11-18 19:37:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
public static StorageId GetStorageId(string ContentPathString)
|
2018-11-18 19:37:41 +00:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
string CleanedPath = ContentPathString.Split(':')[0];
|
2018-11-18 19:37:41 +00:00
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
switch (CleanedPath)
|
2018-11-18 19:37:41 +00:00
|
|
|
|
{
|
|
|
|
|
case ContentPath.SystemContent:
|
|
|
|
|
case ContentPath.System:
|
|
|
|
|
return StorageId.NandSystem;
|
|
|
|
|
|
|
|
|
|
case ContentPath.UserContent:
|
|
|
|
|
case ContentPath.User:
|
|
|
|
|
return StorageId.NandUser;
|
|
|
|
|
|
|
|
|
|
case ContentPath.SdCardContent:
|
|
|
|
|
return StorageId.SdCard;
|
|
|
|
|
|
|
|
|
|
case ContentPath.Host:
|
|
|
|
|
return StorageId.Host;
|
|
|
|
|
|
|
|
|
|
case ContentPath.GamecardApp:
|
|
|
|
|
case ContentPath.GamecardContents:
|
|
|
|
|
case ContentPath.GamecardUpdate:
|
|
|
|
|
return StorageId.GameCard;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return StorageId.None;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|