2018-11-18 12:37:41 -07:00
|
|
|
using LibHac;
|
2018-09-08 16:04:26 -06:00
|
|
|
using Ryujinx.HLE.FileSystem;
|
2018-08-16 17:47:36 -06:00
|
|
|
using Ryujinx.HLE.HOS.Ipc;
|
2018-10-07 07:13:46 -06:00
|
|
|
using Ryujinx.HLE.Utilities;
|
2018-02-24 21:34:16 -07:00
|
|
|
using System.Collections.Generic;
|
2018-11-18 12:37:41 -07:00
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using static Ryujinx.HLE.FileSystem.VirtualFileSystem;
|
|
|
|
using static Ryujinx.HLE.HOS.ErrorCode;
|
|
|
|
using static Ryujinx.HLE.Utilities.StringUtils;
|
2018-02-24 21:34:16 -07:00
|
|
|
|
2018-08-16 17:47:36 -06:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.FspSrv
|
2018-02-24 21:34:16 -07:00
|
|
|
{
|
2018-04-05 22:01:52 -06:00
|
|
|
class IFileSystemProxy : IpcService
|
2018-02-24 21:34:16 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
private Dictionary<int, ServiceProcessRequest> _commands;
|
2018-02-24 21:34:16 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
2018-02-24 21:34:16 -07:00
|
|
|
|
2018-04-05 22:01:52 -06:00
|
|
|
public IFileSystemProxy()
|
2018-02-24 21:34:16 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
_commands = new Dictionary<int, ServiceProcessRequest>
|
2018-02-24 21:34:16 -07:00
|
|
|
{
|
2018-11-18 12:37:41 -07:00
|
|
|
{ 1, Initialize },
|
|
|
|
{ 8, OpenFileSystemWithId },
|
|
|
|
{ 11, OpenBisFileSystem },
|
2018-09-08 16:04:26 -06:00
|
|
|
{ 18, OpenSdCardFileSystem },
|
|
|
|
{ 51, OpenSaveDataFileSystem },
|
|
|
|
{ 52, OpenSaveDataFileSystemBySystemSaveDataId },
|
|
|
|
{ 200, OpenDataStorageByCurrentProcess },
|
2018-11-18 12:37:41 -07:00
|
|
|
{ 202, OpenDataStorageByDataId },
|
2018-09-08 16:04:26 -06:00
|
|
|
{ 203, OpenPatchDataStorageByCurrentProcess },
|
|
|
|
{ 1005, GetGlobalAccessLogMode }
|
2018-02-24 21:34:16 -07:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-11-18 12:37:41 -07:00
|
|
|
// Initialize(u64, pid)
|
2018-12-06 04:16:24 -07:00
|
|
|
public long Initialize(ServiceCtx context)
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OpenFileSystemWithId(nn::fssrv::sf::FileSystemType filesystem_type, nn::ApplicationId tid, buffer<bytes<0x301>, 0x19, 0x301> path)
|
|
|
|
// -> object<nn::fssrv::sf::IFileSystem> contentFs
|
2018-12-06 04:16:24 -07:00
|
|
|
public long OpenFileSystemWithId(ServiceCtx context)
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
FileSystemType fileSystemType = (FileSystemType)context.RequestData.ReadInt32();
|
|
|
|
long titleId = context.RequestData.ReadInt64();
|
|
|
|
string switchPath = ReadUtf8String(context);
|
|
|
|
string fullPath = context.Device.FileSystem.SwitchPathToSystemPath(switchPath);
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (!File.Exists(fullPath))
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
if (fullPath.Contains("."))
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
return OpenFileSystemFromInternalFile(context, fullPath);
|
2018-11-18 12:37:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist);
|
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
FileStream fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read);
|
|
|
|
string extension = Path.GetExtension(fullPath);
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (extension == ".nca")
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
return OpenNcaFs(context, fullPath, fileStream);
|
2018-11-18 12:37:41 -07:00
|
|
|
}
|
2018-12-06 04:16:24 -07:00
|
|
|
else if (extension == ".nsp")
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
return OpenNsp(context, fullPath);
|
2018-11-18 12:37:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return MakeError(ErrorModule.Fs, FsErr.InvalidInput);
|
|
|
|
}
|
|
|
|
|
|
|
|
// OpenBisFileSystem(nn::fssrv::sf::Partition partitionID, buffer<bytes<0x301>, 0x19, 0x301>) -> object<nn::fssrv::sf::IFileSystem> Bis
|
2018-12-06 04:16:24 -07:00
|
|
|
public long OpenBisFileSystem(ServiceCtx context)
|
2018-02-24 21:34:16 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
int bisPartitionId = context.RequestData.ReadInt32();
|
|
|
|
string partitionString = ReadUtf8String(context);
|
|
|
|
string bisPartitonPath = string.Empty;
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
switch (bisPartitionId)
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
|
|
|
case 29:
|
2018-12-06 04:16:24 -07:00
|
|
|
bisPartitonPath = SafeNandPath;
|
2018-11-18 12:37:41 -07:00
|
|
|
break;
|
|
|
|
case 30:
|
|
|
|
case 31:
|
2018-12-06 04:16:24 -07:00
|
|
|
bisPartitonPath = SystemNandPath;
|
2018-11-18 12:37:41 -07:00
|
|
|
break;
|
|
|
|
case 32:
|
2018-12-06 04:16:24 -07:00
|
|
|
bisPartitonPath = UserNandPath;
|
2018-11-18 12:37:41 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return MakeError(ErrorModule.Fs, FsErr.InvalidInput);
|
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
string fullPath = context.Device.FileSystem.GetFullPartitionPath(bisPartitonPath);
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
FileSystemProvider fileSystemProvider = new FileSystemProvider(fullPath, context.Device.FileSystem.GetBasePath());
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
MakeObject(context, new IFileSystem(fullPath, fileSystemProvider));
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-02-24 21:34:16 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-18 12:37:41 -07:00
|
|
|
// OpenSdCardFileSystem() -> object<nn::fssrv::sf::IFileSystem>
|
2018-12-06 04:16:24 -07:00
|
|
|
public long OpenSdCardFileSystem(ServiceCtx context)
|
2018-02-24 21:34:16 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
string sdCardPath = context.Device.FileSystem.GetSdCardPath();
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
FileSystemProvider fileSystemProvider = new FileSystemProvider(sdCardPath, context.Device.FileSystem.GetBasePath());
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
MakeObject(context, new IFileSystem(sdCardPath, fileSystemProvider));
|
2018-02-24 21:34:16 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-18 12:37:41 -07:00
|
|
|
// OpenSaveDataFileSystem(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> saveDataFs
|
2018-12-06 04:16:24 -07:00
|
|
|
public long OpenSaveDataFileSystem(ServiceCtx context)
|
2018-06-02 16:46:09 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
LoadSaveDataFileSystem(context);
|
2018-06-02 16:46:09 -06:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-18 12:37:41 -07:00
|
|
|
// OpenSaveDataFileSystemBySystemSaveDataId(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> systemSaveDataFs
|
2018-12-06 04:16:24 -07:00
|
|
|
public long OpenSaveDataFileSystemBySystemSaveDataId(ServiceCtx context)
|
2018-02-24 21:34:16 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
LoadSaveDataFileSystem(context);
|
2018-02-24 21:34:16 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-18 12:37:41 -07:00
|
|
|
// OpenDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> dataStorage
|
2018-12-06 04:16:24 -07:00
|
|
|
public long OpenDataStorageByCurrentProcess(ServiceCtx context)
|
2018-02-24 21:34:16 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
MakeObject(context, new IStorage(context.Device.FileSystem.RomFs));
|
2018-02-24 21:34:16 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-18 12:37:41 -07:00
|
|
|
// OpenDataStorageByDataId(u8 storageId, nn::ApplicationId tid) -> object<nn::fssrv::sf::IStorage> dataStorage
|
2018-12-06 04:16:24 -07:00
|
|
|
public long OpenDataStorageByDataId(ServiceCtx context)
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
StorageId storageId = (StorageId)context.RequestData.ReadByte();
|
|
|
|
byte[] padding = context.RequestData.ReadBytes(7);
|
|
|
|
long titleId = context.RequestData.ReadInt64();
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-30 06:36:35 -07:00
|
|
|
ContentType contentType = ContentType.Data;
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
StorageId installedStorage =
|
2018-12-30 06:36:35 -07:00
|
|
|
context.Device.System.ContentManager.GetInstalledStorage(titleId, contentType, storageId);
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (installedStorage == StorageId.None)
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-30 06:36:35 -07:00
|
|
|
contentType = ContentType.AocData;
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
installedStorage =
|
2018-12-30 06:36:35 -07:00
|
|
|
context.Device.System.ContentManager.GetInstalledStorage(titleId, contentType, storageId);
|
2018-11-18 12:37:41 -07:00
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (installedStorage != StorageId.None)
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-30 06:36:35 -07:00
|
|
|
string contentPath = context.Device.System.ContentManager.GetInstalledContentPath(titleId, storageId, contentType);
|
2018-12-06 04:16:24 -07:00
|
|
|
string installPath = context.Device.FileSystem.SwitchPathToSystemPath(contentPath);
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (!string.IsNullOrWhiteSpace(installPath))
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
string ncaPath = installPath;
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (File.Exists(ncaPath))
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
FileStream ncaStream = new FileStream(ncaPath, FileMode.Open, FileAccess.Read);
|
|
|
|
Nca nca = new Nca(context.Device.System.KeySet, ncaStream, false);
|
|
|
|
NcaSection romfsSection = nca.Sections.FirstOrDefault(x => x?.Type == SectionType.Romfs);
|
|
|
|
Stream romfsStream = nca.OpenSection(romfsSection.SectionNum, false, context.Device.System.FsIntegrityCheckLevel);
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
MakeObject(context, new IStorage(romfsStream));
|
2018-11-18 12:37:41 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
throw new FileNotFoundException($"No Nca found in Path `{ncaPath}`.");
|
2018-11-18 12:37:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
throw new DirectoryNotFoundException($"Path for title id {titleId:x16} on Storage {storageId} was not found in Path {installPath}.");
|
2018-11-18 12:37:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
throw new FileNotFoundException($"System archive with titleid {titleId:x16} was not found on Storage {storageId}. Found in {installedStorage}.");
|
2018-11-18 12:37:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// OpenPatchDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage>
|
2018-12-06 04:16:24 -07:00
|
|
|
public long OpenPatchDataStorageByCurrentProcess(ServiceCtx context)
|
2018-02-24 21:34:16 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
MakeObject(context, new IStorage(context.Device.FileSystem.RomFs));
|
2018-02-24 21:34:16 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-18 12:37:41 -07:00
|
|
|
// GetGlobalAccessLogMode() -> u32 logMode
|
2018-12-06 04:16:24 -07:00
|
|
|
public long GetGlobalAccessLogMode(ServiceCtx context)
|
2018-02-24 21:34:16 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
context.ResponseData.Write(0);
|
2018-02-24 21:34:16 -07:00
|
|
|
|
|
|
|
return 0;
|
2018-04-05 22:01:52 -06:00
|
|
|
}
|
2018-09-08 16:04:26 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
public void LoadSaveDataFileSystem(ServiceCtx context)
|
2018-09-08 16:04:26 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
SaveSpaceId saveSpaceId = (SaveSpaceId)context.RequestData.ReadInt64();
|
2018-09-08 16:04:26 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
long titleId = context.RequestData.ReadInt64();
|
2018-09-08 16:04:26 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
UInt128 userId = new UInt128(
|
|
|
|
context.RequestData.ReadInt64(),
|
|
|
|
context.RequestData.ReadInt64());
|
2018-09-08 16:04:26 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
long saveId = context.RequestData.ReadInt64();
|
|
|
|
SaveDataType saveDataType = (SaveDataType)context.RequestData.ReadByte();
|
|
|
|
SaveInfo saveInfo = new SaveInfo(titleId, saveId, saveDataType, userId, saveSpaceId);
|
|
|
|
string savePath = context.Device.FileSystem.GetGameSavePath(saveInfo, context);
|
|
|
|
FileSystemProvider fileSystemProvider = new FileSystemProvider(savePath, context.Device.FileSystem.GetBasePath());
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
MakeObject(context, new IFileSystem(savePath, fileSystemProvider));
|
2018-11-18 12:37:41 -07:00
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
private long OpenNsp(ServiceCtx context, string pfsPath)
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
FileStream pfsFile = new FileStream(pfsPath, FileMode.Open, FileAccess.Read);
|
|
|
|
Pfs nsp = new Pfs(pfsFile);
|
|
|
|
PfsFileEntry ticketFile = nsp.Files.FirstOrDefault(x => x.Name.EndsWith(".tik"));
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (ticketFile != null)
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
Ticket ticket = new Ticket(nsp.OpenFile(ticketFile));
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
context.Device.System.KeySet.TitleKeys[ticket.RightsId] =
|
|
|
|
ticket.GetTitleKey(context.Device.System.KeySet);
|
2018-11-18 12:37:41 -07:00
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
IFileSystem nspFileSystem = new IFileSystem(pfsPath, new PFsProvider(nsp));
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
MakeObject(context, nspFileSystem);
|
2018-11-18 12:37:41 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
private long OpenNcaFs(ServiceCtx context,string ncaPath, Stream ncaStream)
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
Nca nca = new Nca(context.Device.System.KeySet, ncaStream, false);
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
NcaSection romfsSection = nca.Sections.FirstOrDefault(x => x?.Type == SectionType.Romfs);
|
|
|
|
NcaSection pfsSection = nca.Sections.FirstOrDefault(x => x?.Type == SectionType.Pfs0);
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (romfsSection != null)
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
Stream romfsStream = nca.OpenSection(romfsSection.SectionNum, false, context.Device.System.FsIntegrityCheckLevel);
|
|
|
|
IFileSystem ncaFileSystem = new IFileSystem(ncaPath, new RomFsProvider(romfsStream));
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
MakeObject(context, ncaFileSystem);
|
2018-11-18 12:37:41 -07:00
|
|
|
}
|
2018-12-06 04:16:24 -07:00
|
|
|
else if(pfsSection !=null)
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
Stream pfsStream = nca.OpenSection(pfsSection.SectionNum, false, context.Device.System.FsIntegrityCheckLevel);
|
|
|
|
Pfs pfs = new Pfs(pfsStream);
|
|
|
|
IFileSystem ncaFileSystem = new IFileSystem(ncaPath, new PFsProvider(pfs));
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
MakeObject(context, ncaFileSystem);
|
2018-11-18 12:37:41 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return MakeError(ErrorModule.Fs, FsErr.PartitionNotFound);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
private long OpenFileSystemFromInternalFile(ServiceCtx context, string fullPath)
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
DirectoryInfo archivePath = new DirectoryInfo(fullPath).Parent;
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
while (string.IsNullOrWhiteSpace(archivePath.Extension))
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
archivePath = archivePath.Parent;
|
2018-11-18 12:37:41 -07:00
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (archivePath.Extension == ".nsp" && File.Exists(archivePath.FullName))
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
FileStream pfsFile = new FileStream(
|
|
|
|
archivePath.FullName.TrimEnd(Path.DirectorySeparatorChar),
|
2018-11-18 12:37:41 -07:00
|
|
|
FileMode.Open,
|
|
|
|
FileAccess.Read);
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
Pfs nsp = new Pfs(pfsFile);
|
|
|
|
PfsFileEntry ticketFile = nsp.Files.FirstOrDefault(x => x.Name.EndsWith(".tik"));
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (ticketFile != null)
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
Ticket ticket = new Ticket(nsp.OpenFile(ticketFile));
|
2018-11-18 12:37:41 -07:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
context.Device.System.KeySet.TitleKeys[ticket.RightsId] =
|
|
|
|
ticket.GetTitleKey(context.Device.System.KeySet);
|
2018-11-18 12:37:41 -07:00
|
|
|
}
|
2018-09-08 16:04:26 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
string filename = fullPath.Replace(archivePath.FullName, string.Empty).TrimStart('\\');
|
2018-09-08 16:04:26 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (nsp.FileExists(filename))
|
2018-11-18 12:37:41 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
return OpenNcaFs(context, fullPath, nsp.OpenFile(filename));
|
2018-11-18 12:37:41 -07:00
|
|
|
}
|
|
|
|
}
|
2018-09-08 16:04:26 -06:00
|
|
|
|
2018-11-18 12:37:41 -07:00
|
|
|
return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist);
|
2018-09-08 16:04:26 -06:00
|
|
|
}
|
2018-02-24 21:34:16 -07:00
|
|
|
}
|
|
|
|
}
|