mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-05-11 12:37:42 +02:00
45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using LibHac;
|
|
using LibHac.Fs.Fsa;
|
|
using LibHac.FsSystem;
|
|
using LibHac.Tools.Fs;
|
|
using LibHac.Tools.FsSystem;
|
|
using Ryujinx.HLE.FileSystem;
|
|
using System.IO;
|
|
|
|
namespace Ryujinx.HLE.Utilities
|
|
{
|
|
public static class PartitionFileSystemUtils
|
|
{
|
|
public static IFileSystem OpenApplicationFileSystem(string path, VirtualFileSystem fileSystem, bool throwOnFailure = true)
|
|
{
|
|
FileStream file = File.OpenRead(path);
|
|
|
|
IFileSystem partitionFileSystem;
|
|
|
|
if (Path.GetExtension(path).ToLower() == ".xci")
|
|
{
|
|
partitionFileSystem = new Xci(fileSystem.KeySet, file.AsStorage()).OpenPartition(XciPartitionType.Secure);
|
|
}
|
|
else
|
|
{
|
|
PartitionFileSystem pfsTemp = new();
|
|
Result initResult = pfsTemp.Initialize(file.AsStorage());
|
|
|
|
if (throwOnFailure)
|
|
{
|
|
initResult.ThrowIfFailure();
|
|
}
|
|
else if (initResult.IsFailure())
|
|
{
|
|
return null;
|
|
}
|
|
|
|
partitionFileSystem = pfsTemp;
|
|
}
|
|
|
|
fileSystem.ImportTickets(partitionFileSystem);
|
|
|
|
return partitionFileSystem;
|
|
}
|
|
}
|
|
}
|