use switch style paths for contentpath
This commit is contained in:
parent
453d335e98
commit
ff1e5ff083
6 changed files with 67 additions and 52 deletions
|
@ -42,20 +42,23 @@ namespace Ryujinx.HLE.FileSystem.Content
|
|||
|
||||
foreach (StorageId StorageId in Enum.GetValues(typeof(StorageId)))
|
||||
{
|
||||
string ContentInstallationDirectory = null;
|
||||
string ContentPathString = null;
|
||||
string ContentDirectory = null;
|
||||
string ContentPathString = null;
|
||||
string RegisteredDirectory = null;
|
||||
|
||||
try
|
||||
{
|
||||
ContentPathString = LocationHelper.GetContentPath(StorageId);
|
||||
ContentInstallationDirectory = LocationHelper.GetRealPath(Device.FileSystem, ContentPathString);
|
||||
ContentPathString = LocationHelper.GetContentRoot(StorageId);
|
||||
ContentDirectory = LocationHelper.GetRealPath(Device.FileSystem, ContentPathString);
|
||||
|
||||
RegisteredDirectory = Path.Combine(ContentDirectory, "registered");
|
||||
}
|
||||
catch (NotSupportedException NEx)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(ContentInstallationDirectory);
|
||||
Directory.CreateDirectory(RegisteredDirectory);
|
||||
|
||||
LinkedList<LocationEntry> LocationList = new LinkedList<LocationEntry>();
|
||||
|
||||
|
@ -64,7 +67,7 @@ namespace Ryujinx.HLE.FileSystem.Content
|
|||
LocationList.AddLast(Entry);
|
||||
}
|
||||
|
||||
foreach (string DirectoryPath in Directory.EnumerateDirectories(ContentInstallationDirectory))
|
||||
foreach (string DirectoryPath in Directory.EnumerateDirectories(RegisteredDirectory))
|
||||
{
|
||||
if (Directory.GetFiles(DirectoryPath).Length > 0)
|
||||
{
|
||||
|
@ -74,7 +77,13 @@ namespace Ryujinx.HLE.FileSystem.Content
|
|||
{
|
||||
Nca Nca = new Nca(Device.System.KeySet, NcaFile, false);
|
||||
|
||||
LocationEntry Entry = new LocationEntry(ContentPathString,
|
||||
string SwitchPath = Path.Combine(ContentPathString + ":",
|
||||
NcaFile.Name.Replace(ContentDirectory, string.Empty).TrimStart('\\'));
|
||||
|
||||
// Change path format to switch's
|
||||
SwitchPath = SwitchPath.Replace('\\', '/');
|
||||
|
||||
LocationEntry Entry = new LocationEntry(SwitchPath,
|
||||
0,
|
||||
(long)Nca.Header.TitleId,
|
||||
Nca.Header.ContentType);
|
||||
|
@ -93,7 +102,7 @@ namespace Ryujinx.HLE.FileSystem.Content
|
|||
}
|
||||
}
|
||||
|
||||
foreach (string FilePath in Directory.EnumerateFiles(ContentInstallationDirectory))
|
||||
foreach (string FilePath in Directory.EnumerateFiles(ContentDirectory))
|
||||
{
|
||||
if (Path.GetExtension(FilePath) == ".nca")
|
||||
{
|
||||
|
@ -103,7 +112,13 @@ namespace Ryujinx.HLE.FileSystem.Content
|
|||
{
|
||||
Nca Nca = new Nca(Device.System.KeySet, NcaFile, false);
|
||||
|
||||
LocationEntry Entry = new LocationEntry(ContentPathString,
|
||||
string SwitchPath = Path.Combine(ContentPathString + ":",
|
||||
FilePath.Replace(ContentDirectory, string.Empty).TrimStart('\\'));
|
||||
|
||||
// Change path format to switch's
|
||||
SwitchPath = SwitchPath.Replace('\\', '/');
|
||||
|
||||
LocationEntry Entry = new LocationEntry(SwitchPath,
|
||||
0,
|
||||
(long)Nca.Header.TitleId,
|
||||
Nca.Header.ContentType);
|
||||
|
@ -157,6 +172,24 @@ namespace Ryujinx.HLE.FileSystem.Content
|
|||
}
|
||||
}
|
||||
|
||||
public bool HasNca(string NcaId, StorageId StorageId)
|
||||
{
|
||||
if (ContentDictionary.ContainsValue(NcaId))
|
||||
{
|
||||
var Content = ContentDictionary.FirstOrDefault(x => x.Value == NcaId);
|
||||
|
||||
long TitleId = (long)Content.Key.Item1;
|
||||
|
||||
ContentType ContentType = Content.Key.Item2;
|
||||
|
||||
StorageId Storage = GetInstalledStorage(TitleId, ContentType, StorageId);
|
||||
|
||||
return Storage == StorageId;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public UInt128 GetInstalledNcaId(long TitleId, ContentType ContentType)
|
||||
{
|
||||
if (ContentDictionary.ContainsKey(((ulong)TitleId,ContentType)))
|
||||
|
@ -167,22 +200,6 @@ namespace Ryujinx.HLE.FileSystem.Content
|
|||
return new UInt128();
|
||||
}
|
||||
|
||||
public string GetInstalledPath(long TitleId, ContentType ContentType, StorageId StorageId)
|
||||
{
|
||||
LocationEntry LocationEntry = GetLocation(TitleId, ContentType, StorageId);
|
||||
|
||||
string ContentPath = LocationHelper.GetRealPath(Device.FileSystem, LocationEntry.ContentPath);
|
||||
|
||||
string NcaPath = Path.Combine(ContentPath, ContentDictionary[((ulong)TitleId, ContentType)]) + ".nca";
|
||||
|
||||
if (!File.Exists(NcaPath))
|
||||
{
|
||||
NcaPath = Path.Combine(NcaPath, "00");
|
||||
}
|
||||
|
||||
return NcaPath;
|
||||
}
|
||||
|
||||
public StorageId GetInstalledStorage(long TitleId, ContentType ContentType, StorageId StorageId)
|
||||
{
|
||||
LocationEntry LocationEntry = GetLocation(TitleId, ContentType, StorageId);
|
||||
|
@ -191,7 +208,7 @@ namespace Ryujinx.HLE.FileSystem.Content
|
|||
LocationHelper.GetStorageId(LocationEntry.ContentPath) : StorageId.None;
|
||||
}
|
||||
|
||||
public string GetInstalledContentStorage(long TitleId, StorageId StorageId, ContentType ContentType)
|
||||
public string GetInstalledContentPath(long TitleId, StorageId StorageId, ContentType ContentType)
|
||||
{
|
||||
LocationEntry LocationEntry = GetLocation(TitleId, ContentType, StorageId);
|
||||
|
||||
|
@ -219,7 +236,7 @@ namespace Ryujinx.HLE.FileSystem.Content
|
|||
{
|
||||
StorageId StorageId = LocationHelper.GetStorageId(LocationEntry.ContentPath);
|
||||
|
||||
string InstalledPath = GetInstalledPath(LocationEntry.TitleId, ContentType, StorageId);
|
||||
string InstalledPath = Device.FileSystem.SwitchPathToSystemPath(LocationEntry.ContentPath);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(InstalledPath))
|
||||
{
|
||||
|
|
|
@ -14,11 +14,11 @@ namespace Ryujinx.HLE.FileSystem.Content
|
|||
switch (SwitchContentPath)
|
||||
{
|
||||
case ContentPath.SystemContent:
|
||||
return Path.Combine(FileSystem.GetBasePath(), SystemNandPath, "Contents", "registered");
|
||||
return Path.Combine(FileSystem.GetBasePath(), SystemNandPath, "Contents");
|
||||
case ContentPath.UserContent:
|
||||
return Path.Combine(FileSystem.GetBasePath(), UserNandPath, "Contents", "registered");
|
||||
return Path.Combine(FileSystem.GetBasePath(), UserNandPath, "Contents");
|
||||
case ContentPath.SdCardContent:
|
||||
return Path.Combine(FileSystem.GetSdCardPath(), "Nintendo", "Contents", "registered");
|
||||
return Path.Combine(FileSystem.GetSdCardPath(), "Nintendo", "Contents");
|
||||
case ContentPath.System:
|
||||
return Path.Combine(BasePath, SystemNandPath);
|
||||
case ContentPath.User:
|
||||
|
@ -43,7 +43,7 @@ namespace Ryujinx.HLE.FileSystem.Content
|
|||
}
|
||||
}
|
||||
|
||||
public static string GetContentPath(StorageId StorageId)
|
||||
public static string GetContentRoot(StorageId StorageId)
|
||||
{
|
||||
switch (StorageId)
|
||||
{
|
||||
|
@ -60,7 +60,9 @@ namespace Ryujinx.HLE.FileSystem.Content
|
|||
|
||||
public static StorageId GetStorageId(string ContentPathString)
|
||||
{
|
||||
switch (ContentPathString)
|
||||
string CleanedPath = ContentPathString.Split(':')[0];
|
||||
|
||||
switch (CleanedPath)
|
||||
{
|
||||
case ContentPath.SystemContent:
|
||||
case ContentPath.System:
|
||||
|
|
|
@ -54,9 +54,11 @@ namespace Ryujinx.HLE.HOS.Font
|
|||
{
|
||||
if (ContentManager.TryGetFontTitle(Name, out long FontTitle))
|
||||
{
|
||||
string FontContentPath = ContentManager.GetInstalledPath(FontTitle, ContentType.Data, StorageId.NandSystem);
|
||||
string ContentPath = ContentManager.GetInstalledContentPath(FontTitle, StorageId.NandSystem, ContentType.Data);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(FontContentPath))
|
||||
string FontPath = Device.FileSystem.SwitchPathToSystemPath(ContentPath);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(FontPath))
|
||||
{
|
||||
int FileIndex = 0;
|
||||
|
||||
|
@ -66,7 +68,7 @@ namespace Ryujinx.HLE.HOS.Font
|
|||
FileIndex = 1;
|
||||
}
|
||||
|
||||
FileStream NcaFileStream = new FileStream(FontContentPath, FileMode.Open, FileAccess.Read);
|
||||
FileStream NcaFileStream = new FileStream(FontPath, FileMode.Open, FileAccess.Read);
|
||||
|
||||
Nca Nca = new Nca(Device.System.KeySet, NcaFileStream, false);
|
||||
|
||||
|
|
|
@ -160,21 +160,13 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
|
||||
if (InstalledStorage != StorageId.None)
|
||||
{
|
||||
string InstallPath =
|
||||
Context.Device.System.ContentManager.GetInstalledPath(TitleId, ContentType.AocData, StorageId);
|
||||
string ContentPath = Context.Device.System.ContentManager.GetInstalledContentPath(TitleId, StorageId, ContentType.AocData);
|
||||
|
||||
UInt128 NcaId = Context.Device.System.ContentManager.GetInstalledNcaId(TitleId, ContentType.AocData);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(InstallPath))
|
||||
if (string.IsNullOrWhiteSpace(ContentPath))
|
||||
{
|
||||
InstallPath =
|
||||
Context.Device.System.ContentManager.GetInstalledPath(TitleId, ContentType.Data, StorageId);
|
||||
}
|
||||
|
||||
if ((NcaId.High | NcaId.Low) == 0)
|
||||
{
|
||||
NcaId = Context.Device.System.ContentManager.GetInstalledNcaId(TitleId, ContentType.Data);
|
||||
ContentPath = Context.Device.System.ContentManager.GetInstalledContentPath(TitleId, StorageId, ContentType.AocData);
|
||||
}
|
||||
string InstallPath = Context.Device.FileSystem.SwitchPathToSystemPath(ContentPath);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(InstallPath))
|
||||
{
|
||||
|
|
|
@ -221,7 +221,7 @@ namespace Ryujinx.HLE.HOS.Services.Lr
|
|||
{
|
||||
ContentManager ContentManager = Context.Device.System.ContentManager;
|
||||
|
||||
string ContentPath = ContentManager.GetInstalledContentStorage(TitleId, StorageId, ContentType.Program);
|
||||
string ContentPath = ContentManager.GetInstalledContentPath(TitleId, StorageId, ContentType.Program);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(ContentPath))
|
||||
{
|
||||
|
@ -244,7 +244,7 @@ namespace Ryujinx.HLE.HOS.Services.Lr
|
|||
{
|
||||
ContentManager ContentManager = Context.Device.System.ContentManager;
|
||||
|
||||
string ContentPath = ContentManager.GetInstalledContentStorage(TitleId, StorageId, ContentType.Manual);
|
||||
string ContentPath = ContentManager.GetInstalledContentPath(TitleId, StorageId, ContentType.Manual);
|
||||
|
||||
ContentManager.ClearEntry(TitleId, ContentType.Manual, StorageId);
|
||||
}
|
||||
|
|
|
@ -172,14 +172,16 @@ namespace Ryujinx.HLE.HOS.Services.Set
|
|||
|
||||
long TitleId = 0x0100000000000809;
|
||||
|
||||
string Path = Device.System.ContentManager.GetInstalledPath(TitleId, ContentType.Data, StorageId.NandSystem);
|
||||
string ContentPath = Device.System.ContentManager.GetInstalledContentPath(TitleId, StorageId.NandSystem, ContentType.Data);
|
||||
|
||||
if(string.IsNullOrWhiteSpace(Path))
|
||||
if(string.IsNullOrWhiteSpace(ContentPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
FileStream FirmwareStream = File.Open(Path, FileMode.Open, FileAccess.Read);
|
||||
string FirmwareTitlePath = Device.FileSystem.SwitchPathToSystemPath(ContentPath);
|
||||
|
||||
FileStream FirmwareStream = File.Open(FirmwareTitlePath, FileMode.Open, FileAccess.Read);
|
||||
|
||||
Nca FirmwareContent = new Nca(Device.System.KeySet, FirmwareStream, false);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue