From fe8fbb6fb9b85a528ddfa4848ec8e35fd9a5e9a5 Mon Sep 17 00:00:00 2001 From: emmauss <emmausssss@gmail.com> Date: Sun, 18 Nov 2018 21:37:41 +0200 Subject: 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 --- Ryujinx.HLE/FileSystem/VirtualFileSystem.cs | 39 +++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'Ryujinx.HLE/FileSystem/VirtualFileSystem.cs') diff --git a/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs b/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs index e621ec2b..6bb2847f 100644 --- a/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs +++ b/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs @@ -1,3 +1,4 @@ +using Ryujinx.HLE.FileSystem.Content; using Ryujinx.HLE.HOS; using System; using System.IO; @@ -11,6 +12,7 @@ namespace Ryujinx.HLE.FileSystem public const string SdCardPath = "sdmc"; public const string SystemPath = "system"; + public static string SafeNandPath = Path.Combine(NandPath, "safe"); public static string SystemNandPath = Path.Combine(NandPath, "system"); public static string UserNandPath = Path.Combine(NandPath, "user"); @@ -63,9 +65,15 @@ namespace Ryujinx.HLE.FileSystem return MakeDirAndGetFullPath(SaveHelper.GetSavePath(Save, Context)); } + public string GetFullPartitionPath(string PartitionPath) + { + return MakeDirAndGetFullPath(PartitionPath); + } + public string SwitchPathToSystemPath(string SwitchPath) { string[] Parts = SwitchPath.Split(":"); + if (Parts.Length != 2) { return null; @@ -76,10 +84,12 @@ namespace Ryujinx.HLE.FileSystem public string SystemPathToSwitchPath(string SystemPath) { string BaseSystemPath = GetBasePath() + Path.DirectorySeparatorChar; + if (SystemPath.StartsWith(BaseSystemPath)) { - string RawPath = SystemPath.Replace(BaseSystemPath, ""); - int FirstSeparatorOffset = RawPath.IndexOf(Path.DirectorySeparatorChar); + string RawPath = SystemPath.Replace(BaseSystemPath, ""); + int FirstSeparatorOffset = RawPath.IndexOf(Path.DirectorySeparatorChar); + if (FirstSeparatorOffset == -1) { return $"{RawPath}:/"; @@ -87,6 +97,7 @@ namespace Ryujinx.HLE.FileSystem string BasePath = RawPath.Substring(0, FirstSeparatorOffset); string FileName = RawPath.Substring(FirstSeparatorOffset + 1); + return $"{BasePath}:/{FileName}"; } return null; @@ -94,6 +105,30 @@ namespace Ryujinx.HLE.FileSystem private string MakeDirAndGetFullPath(string Dir) { + // Handles Common Switch Content Paths + switch (Dir) + { + case ContentPath.SdCard: + case "@Sdcard": + Dir = SdCardPath; + break; + case ContentPath.User: + Dir = UserNandPath; + break; + case ContentPath.System: + Dir = SystemNandPath; + break; + case ContentPath.SdCardContent: + Dir = Path.Combine(SdCardPath, "Nintendo", "Contents"); + break; + case ContentPath.UserContent: + Dir = Path.Combine(UserNandPath, "Contents"); + break; + case ContentPath.SystemContent: + Dir = Path.Combine(SystemNandPath, "Contents"); + break; + } + string FullPath = Path.Combine(GetBasePath(), Dir); if (!Directory.Exists(FullPath)) -- cgit v1.2.3-70-g09d2