aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/FileSystem/VirtualFileSystem.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/VirtualFileSystem.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/VirtualFileSystem.cs')
-rw-r--r--Ryujinx.HLE/FileSystem/VirtualFileSystem.cs39
1 files changed, 37 insertions, 2 deletions
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))