aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/FileSystem/Content/LocationHelper.cs
diff options
context:
space:
mode:
authoremmauss <emmausssss@gmail.com>2018-11-18 21:37:41 +0200
committergdkchan <gab.dark.100@gmail.com>2018-11-18 17:37:41 -0200
commitfe8fbb6fb9b85a528ddfa4848ec8e35fd9a5e9a5 (patch)
tree7cd33a50d1ebc98e467df93aeb86315679110778 /Ryujinx.HLE/FileSystem/Content/LocationHelper.cs
parente603b7afbcdff0fc732304872f5a65d410c601f9 (diff)
Implement ContentManager and related services (#438)
* Implement contentmanager and related services * small changes * read system firmware version from nand * add pfs support, write directoryentry info for romfs files * add file check in fsp-srv:8 * add support for open fs of internal files * fix filename when accessing pfs * use switch style paths for contentpath * close nca after verifying type * removed publishing profiles, align directory entry * fix style * lots of style fixes * yasf(yet another style fix) * yasf(yet another style fix) plus symbols * enforce path check on every fs access * change enum type to default * fix typo
Diffstat (limited to 'Ryujinx.HLE/FileSystem/Content/LocationHelper.cs')
-rw-r--r--Ryujinx.HLE/FileSystem/Content/LocationHelper.cs91
1 files changed, 91 insertions, 0 deletions
diff --git a/Ryujinx.HLE/FileSystem/Content/LocationHelper.cs b/Ryujinx.HLE/FileSystem/Content/LocationHelper.cs
new file mode 100644
index 00000000..75b59431
--- /dev/null
+++ b/Ryujinx.HLE/FileSystem/Content/LocationHelper.cs
@@ -0,0 +1,91 @@
+using System;
+using System.IO;
+
+using static Ryujinx.HLE.FileSystem.VirtualFileSystem;
+
+namespace Ryujinx.HLE.FileSystem.Content
+{
+ internal static class LocationHelper
+ {
+ public static string GetRealPath(VirtualFileSystem FileSystem, string SwitchContentPath)
+ {
+ string BasePath = FileSystem.GetBasePath();
+
+ switch (SwitchContentPath)
+ {
+ case ContentPath.SystemContent:
+ return Path.Combine(FileSystem.GetBasePath(), SystemNandPath, "Contents");
+ case ContentPath.UserContent:
+ return Path.Combine(FileSystem.GetBasePath(), UserNandPath, "Contents");
+ case ContentPath.SdCardContent:
+ return Path.Combine(FileSystem.GetSdCardPath(), "Nintendo", "Contents");
+ case ContentPath.System:
+ return Path.Combine(BasePath, SystemNandPath);
+ case ContentPath.User:
+ return Path.Combine(BasePath, UserNandPath);
+ default:
+ throw new NotSupportedException($"Content Path `{SwitchContentPath}` is not supported.");
+ }
+ }
+
+ public static string GetContentPath(ContentStorageId ContentStorageId)
+ {
+ switch (ContentStorageId)
+ {
+ case ContentStorageId.NandSystem:
+ return ContentPath.SystemContent;
+ case ContentStorageId.NandUser:
+ return ContentPath.UserContent;
+ case ContentStorageId.SdCard:
+ return ContentPath.SdCardContent;
+ default:
+ throw new NotSupportedException($"Content Storage `{ContentStorageId}` is not supported.");
+ }
+ }
+
+ public static string GetContentRoot(StorageId StorageId)
+ {
+ switch (StorageId)
+ {
+ case StorageId.NandSystem:
+ return ContentPath.SystemContent;
+ case StorageId.NandUser:
+ return ContentPath.UserContent;
+ case StorageId.SdCard:
+ return ContentPath.SdCardContent;
+ default:
+ throw new NotSupportedException($"Storage Id `{StorageId}` is not supported.");
+ }
+ }
+
+ public static StorageId GetStorageId(string ContentPathString)
+ {
+ string CleanedPath = ContentPathString.Split(':')[0];
+
+ switch (CleanedPath)
+ {
+ 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;
+ }
+ }
+ }
+}