PartitionFileSystemUtils.cs
1 using LibHac; 2 using LibHac.Fs.Fsa; 3 using LibHac.FsSystem; 4 using LibHac.Tools.Fs; 5 using LibHac.Tools.FsSystem; 6 using Ryujinx.HLE.FileSystem; 7 using System.IO; 8 9 namespace Ryujinx.HLE.Utilities 10 { 11 public static class PartitionFileSystemUtils 12 { 13 public static IFileSystem OpenApplicationFileSystem(string path, VirtualFileSystem fileSystem, bool throwOnFailure = true) 14 { 15 FileStream file = File.OpenRead(path); 16 17 IFileSystem partitionFileSystem; 18 19 if (Path.GetExtension(path).ToLower() == ".xci") 20 { 21 partitionFileSystem = new Xci(fileSystem.KeySet, file.AsStorage()).OpenPartition(XciPartitionType.Secure); 22 } 23 else 24 { 25 var pfsTemp = new PartitionFileSystem(); 26 Result initResult = pfsTemp.Initialize(file.AsStorage()); 27 28 if (throwOnFailure) 29 { 30 initResult.ThrowIfFailure(); 31 } 32 else if (initResult.IsFailure()) 33 { 34 return null; 35 } 36 37 partitionFileSystem = pfsTemp; 38 } 39 40 fileSystem.ImportTickets(partitionFileSystem); 41 42 return partitionFileSystem; 43 } 44 } 45 }