2018-11-18 14:37:41 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
using static Ryujinx.HLE.FileSystem.VirtualFileSystem;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.FileSystem.Content
|
|
|
|
|
{
|
|
|
|
|
internal static class LocationHelper
|
|
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
|
public static string GetRealPath(VirtualFileSystem fileSystem, string switchContentPath)
|
2018-11-18 14:37:41 -05:00
|
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
|
string basePath = fileSystem.GetBasePath();
|
2018-11-18 14:37:41 -05:00
|
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
|
switch (switchContentPath)
|
2018-11-18 14:37:41 -05:00
|
|
|
|
{
|
|
|
|
|
case ContentPath.SystemContent:
|
2018-12-06 06:16:24 -05:00
|
|
|
|
return Path.Combine(fileSystem.GetBasePath(), SystemNandPath, "Contents");
|
2018-11-18 14:37:41 -05:00
|
|
|
|
case ContentPath.UserContent:
|
2018-12-06 06:16:24 -05:00
|
|
|
|
return Path.Combine(fileSystem.GetBasePath(), UserNandPath, "Contents");
|
2018-11-18 14:37:41 -05:00
|
|
|
|
case ContentPath.SdCardContent:
|
2018-12-06 06:16:24 -05:00
|
|
|
|
return Path.Combine(fileSystem.GetSdCardPath(), "Nintendo", "Contents");
|
2018-11-18 14:37:41 -05:00
|
|
|
|
case ContentPath.System:
|
2018-12-06 06:16:24 -05:00
|
|
|
|
return Path.Combine(basePath, SystemNandPath);
|
2018-11-18 14:37:41 -05:00
|
|
|
|
case ContentPath.User:
|
2018-12-06 06:16:24 -05:00
|
|
|
|
return Path.Combine(basePath, UserNandPath);
|
2018-11-18 14:37:41 -05:00
|
|
|
|
default:
|
2018-12-06 06:16:24 -05:00
|
|
|
|
throw new NotSupportedException($"Content Path `{switchContentPath}` is not supported.");
|
2018-11-18 14:37:41 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
|
public static string GetContentPath(ContentStorageId contentStorageId)
|
2018-11-18 14:37:41 -05:00
|
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
|
switch (contentStorageId)
|
2018-11-18 14:37:41 -05:00
|
|
|
|
{
|
|
|
|
|
case ContentStorageId.NandSystem:
|
|
|
|
|
return ContentPath.SystemContent;
|
|
|
|
|
case ContentStorageId.NandUser:
|
|
|
|
|
return ContentPath.UserContent;
|
|
|
|
|
case ContentStorageId.SdCard:
|
|
|
|
|
return ContentPath.SdCardContent;
|
|
|
|
|
default:
|
2018-12-06 06:16:24 -05:00
|
|
|
|
throw new NotSupportedException($"Content Storage `{contentStorageId}` is not supported.");
|
2018-11-18 14:37:41 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
|
public static string GetContentRoot(StorageId storageId)
|
2018-11-18 14:37:41 -05:00
|
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
|
switch (storageId)
|
2018-11-18 14:37:41 -05:00
|
|
|
|
{
|
|
|
|
|
case StorageId.NandSystem:
|
|
|
|
|
return ContentPath.SystemContent;
|
|
|
|
|
case StorageId.NandUser:
|
|
|
|
|
return ContentPath.UserContent;
|
|
|
|
|
case StorageId.SdCard:
|
|
|
|
|
return ContentPath.SdCardContent;
|
|
|
|
|
default:
|
2018-12-06 06:16:24 -05:00
|
|
|
|
throw new NotSupportedException($"Storage Id `{storageId}` is not supported.");
|
2018-11-18 14:37:41 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
|
public static StorageId GetStorageId(string contentPathString)
|
2018-11-18 14:37:41 -05:00
|
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
|
string cleanedPath = contentPathString.Split(':')[0];
|
2018-11-18 14:37:41 -05:00
|
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
|
switch (cleanedPath)
|
2018-11-18 14:37:41 -05: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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|