2018-11-18 20:37:41 +01:00
|
|
|
using LibHac;
|
2019-06-01 02:31:10 +02:00
|
|
|
using LibHac.Fs;
|
|
|
|
using LibHac.Fs.NcaUtils;
|
2019-06-16 03:31:18 +02:00
|
|
|
using Ryujinx.Common.Logging;
|
2018-09-09 00:04:26 +02:00
|
|
|
using Ryujinx.HLE.FileSystem;
|
2018-08-17 01:47:36 +02:00
|
|
|
using Ryujinx.HLE.HOS.Ipc;
|
2018-10-07 15:13:46 +02:00
|
|
|
using Ryujinx.HLE.Utilities;
|
2018-02-25 05:34:16 +01:00
|
|
|
using System.Collections.Generic;
|
2018-11-18 20:37:41 +01:00
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
using static Ryujinx.HLE.FileSystem.VirtualFileSystem;
|
|
|
|
using static Ryujinx.HLE.HOS.ErrorCode;
|
|
|
|
using static Ryujinx.HLE.Utilities.StringUtils;
|
2018-02-25 05:34:16 +01:00
|
|
|
|
2018-08-17 01:47:36 +02:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.FspSrv
|
2018-02-25 05:34:16 +01:00
|
|
|
{
|
2018-04-06 06:01:52 +02:00
|
|
|
class IFileSystemProxy : IpcService
|
2018-02-25 05:34:16 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
private Dictionary<int, ServiceProcessRequest> _commands;
|
2018-02-25 05:34:16 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
2018-02-25 05:34:16 +01:00
|
|
|
|
2018-04-06 06:01:52 +02:00
|
|
|
public IFileSystemProxy()
|
2018-02-25 05:34:16 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
_commands = new Dictionary<int, ServiceProcessRequest>
|
2018-02-25 05:34:16 +01:00
|
|
|
{
|
2018-11-18 20:37:41 +01:00
|
|
|
{ 1, Initialize },
|
|
|
|
{ 8, OpenFileSystemWithId },
|
|
|
|
{ 11, OpenBisFileSystem },
|
2018-09-09 00:04:26 +02:00
|
|
|
{ 18, OpenSdCardFileSystem },
|
|
|
|
{ 51, OpenSaveDataFileSystem },
|
|
|
|
{ 52, OpenSaveDataFileSystemBySystemSaveDataId },
|
|
|
|
{ 200, OpenDataStorageByCurrentProcess },
|
2018-11-18 20:37:41 +01:00
|
|
|
{ 202, OpenDataStorageByDataId },
|
2018-09-09 00:04:26 +02:00
|
|
|
{ 203, OpenPatchDataStorageByCurrentProcess },
|
2019-06-16 03:31:18 +02:00
|
|
|
{ 1005, GetGlobalAccessLogMode },
|
|
|
|
{ 1006, OutputAccessLogToSdCard }
|
2018-02-25 05:34:16 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-11-18 20:37:41 +01:00
|
|
|
// Initialize(u64, pid)
|
2018-12-06 12:16:24 +01:00
|
|
|
public long Initialize(ServiceCtx context)
|
2018-11-18 20:37:41 +01: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 12:16:24 +01:00
|
|
|
public long OpenFileSystemWithId(ServiceCtx context)
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01: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 20:37:41 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
if (!File.Exists(fullPath))
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
if (fullPath.Contains("."))
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
return OpenFileSystemFromInternalFile(context, fullPath);
|
2018-11-18 20:37:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist);
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
FileStream fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read);
|
|
|
|
string extension = Path.GetExtension(fullPath);
|
2018-11-18 20:37:41 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
if (extension == ".nca")
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
2019-01-05 01:41:49 +01:00
|
|
|
return OpenNcaFs(context, fullPath, fileStream.AsStorage());
|
2018-11-18 20:37:41 +01:00
|
|
|
}
|
2018-12-06 12:16:24 +01:00
|
|
|
else if (extension == ".nsp")
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
return OpenNsp(context, fullPath);
|
2018-11-18 20:37:41 +01: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 12:16:24 +01:00
|
|
|
public long OpenBisFileSystem(ServiceCtx context)
|
2018-02-25 05:34:16 +01:00
|
|
|
{
|
2019-06-01 02:31:10 +02:00
|
|
|
int bisPartitionId = context.RequestData.ReadInt32();
|
|
|
|
string partitionString = ReadUtf8String(context);
|
|
|
|
string bisPartitionPath = string.Empty;
|
2018-11-18 20:37:41 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
switch (bisPartitionId)
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
|
|
|
case 29:
|
2019-06-01 02:31:10 +02:00
|
|
|
bisPartitionPath = SafeNandPath;
|
2018-11-18 20:37:41 +01:00
|
|
|
break;
|
|
|
|
case 30:
|
|
|
|
case 31:
|
2019-06-01 02:31:10 +02:00
|
|
|
bisPartitionPath = SystemNandPath;
|
2018-11-18 20:37:41 +01:00
|
|
|
break;
|
|
|
|
case 32:
|
2019-06-01 02:31:10 +02:00
|
|
|
bisPartitionPath = UserNandPath;
|
2018-11-18 20:37:41 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return MakeError(ErrorModule.Fs, FsErr.InvalidInput);
|
|
|
|
}
|
|
|
|
|
2019-06-01 02:31:10 +02:00
|
|
|
string fullPath = context.Device.FileSystem.GetFullPartitionPath(bisPartitionPath);
|
2018-11-18 20:37:41 +01:00
|
|
|
|
2019-06-01 02:31:10 +02:00
|
|
|
LocalFileSystem fileSystem = new LocalFileSystem(fullPath);
|
2018-11-18 20:37:41 +01:00
|
|
|
|
2019-06-01 02:31:10 +02:00
|
|
|
MakeObject(context, new IFileSystem(fileSystem));
|
2018-11-18 20:37:41 +01:00
|
|
|
|
2018-02-25 05:34:16 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-18 20:37:41 +01:00
|
|
|
// OpenSdCardFileSystem() -> object<nn::fssrv::sf::IFileSystem>
|
2018-12-06 12:16:24 +01:00
|
|
|
public long OpenSdCardFileSystem(ServiceCtx context)
|
2018-02-25 05:34:16 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
string sdCardPath = context.Device.FileSystem.GetSdCardPath();
|
2018-11-18 20:37:41 +01:00
|
|
|
|
2019-06-01 02:31:10 +02:00
|
|
|
LocalFileSystem fileSystem = new LocalFileSystem(sdCardPath);
|
2018-11-18 20:37:41 +01:00
|
|
|
|
2019-06-01 02:31:10 +02:00
|
|
|
MakeObject(context, new IFileSystem(fileSystem));
|
2018-02-25 05:34:16 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-18 20:37:41 +01:00
|
|
|
// OpenSaveDataFileSystem(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> saveDataFs
|
2018-12-06 12:16:24 +01:00
|
|
|
public long OpenSaveDataFileSystem(ServiceCtx context)
|
2018-06-03 00:46:09 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
LoadSaveDataFileSystem(context);
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-18 20:37:41 +01:00
|
|
|
// OpenSaveDataFileSystemBySystemSaveDataId(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> systemSaveDataFs
|
2018-12-06 12:16:24 +01:00
|
|
|
public long OpenSaveDataFileSystemBySystemSaveDataId(ServiceCtx context)
|
2018-02-25 05:34:16 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
LoadSaveDataFileSystem(context);
|
2018-02-25 05:34:16 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-18 20:37:41 +01:00
|
|
|
// OpenDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> dataStorage
|
2018-12-06 12:16:24 +01:00
|
|
|
public long OpenDataStorageByCurrentProcess(ServiceCtx context)
|
2018-02-25 05:34:16 +01:00
|
|
|
{
|
2019-06-01 02:31:10 +02:00
|
|
|
MakeObject(context, new IStorage(context.Device.FileSystem.RomFs.AsStorage()));
|
2018-02-25 05:34:16 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-18 20:37:41 +01:00
|
|
|
// OpenDataStorageByDataId(u8 storageId, nn::ApplicationId tid) -> object<nn::fssrv::sf::IStorage> dataStorage
|
2018-12-06 12:16:24 +01:00
|
|
|
public long OpenDataStorageByDataId(ServiceCtx context)
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
StorageId storageId = (StorageId)context.RequestData.ReadByte();
|
|
|
|
byte[] padding = context.RequestData.ReadBytes(7);
|
|
|
|
long titleId = context.RequestData.ReadInt64();
|
2018-11-18 20:37:41 +01:00
|
|
|
|
2018-12-30 14:36:35 +01:00
|
|
|
ContentType contentType = ContentType.Data;
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
StorageId installedStorage =
|
2018-12-30 14:36:35 +01:00
|
|
|
context.Device.System.ContentManager.GetInstalledStorage(titleId, contentType, storageId);
|
2018-11-18 20:37:41 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
if (installedStorage == StorageId.None)
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
2019-06-01 02:31:10 +02:00
|
|
|
contentType = ContentType.PublicData;
|
2018-12-30 14:36:35 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
installedStorage =
|
2018-12-30 14:36:35 +01:00
|
|
|
context.Device.System.ContentManager.GetInstalledStorage(titleId, contentType, storageId);
|
2018-11-18 20:37:41 +01:00
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
if (installedStorage != StorageId.None)
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
2018-12-30 14:36:35 +01:00
|
|
|
string contentPath = context.Device.System.ContentManager.GetInstalledContentPath(titleId, storageId, contentType);
|
2018-12-06 12:16:24 +01:00
|
|
|
string installPath = context.Device.FileSystem.SwitchPathToSystemPath(contentPath);
|
2018-11-18 20:37:41 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
if (!string.IsNullOrWhiteSpace(installPath))
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
string ncaPath = installPath;
|
2018-11-18 20:37:41 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
if (File.Exists(ncaPath))
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
2019-06-01 02:31:10 +02:00
|
|
|
LibHac.Fs.IStorage ncaStorage = new LocalStorage(ncaPath, FileAccess.Read, FileMode.Open);
|
|
|
|
Nca nca = new Nca(context.Device.System.KeySet, ncaStorage);
|
|
|
|
LibHac.Fs.IStorage romfsStorage = nca.OpenStorage(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
|
2018-11-18 20:37:41 +01:00
|
|
|
|
2019-06-01 02:31:10 +02:00
|
|
|
MakeObject(context, new IStorage(romfsStorage));
|
2018-11-18 20:37:41 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
throw new FileNotFoundException($"No Nca found in Path `{ncaPath}`.");
|
2018-11-18 20:37:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
throw new DirectoryNotFoundException($"Path for title id {titleId:x16} on Storage {storageId} was not found in Path {installPath}.");
|
2018-11-18 20:37:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
throw new FileNotFoundException($"System archive with titleid {titleId:x16} was not found on Storage {storageId}. Found in {installedStorage}.");
|
2018-11-18 20:37:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// OpenPatchDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage>
|
2018-12-06 12:16:24 +01:00
|
|
|
public long OpenPatchDataStorageByCurrentProcess(ServiceCtx context)
|
2018-02-25 05:34:16 +01:00
|
|
|
{
|
2019-06-01 02:31:10 +02:00
|
|
|
MakeObject(context, new IStorage(context.Device.FileSystem.RomFs.AsStorage()));
|
2018-02-25 05:34:16 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-18 20:37:41 +01:00
|
|
|
// GetGlobalAccessLogMode() -> u32 logMode
|
2018-12-06 12:16:24 +01:00
|
|
|
public long GetGlobalAccessLogMode(ServiceCtx context)
|
2018-02-25 05:34:16 +01:00
|
|
|
{
|
2019-06-16 03:31:18 +02:00
|
|
|
int mode = context.Device.System.GlobalAccessLogMode;
|
|
|
|
|
|
|
|
context.ResponseData.Write(mode);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OutputAccessLogToSdCard(buffer<bytes, 5> log_text)
|
|
|
|
public long OutputAccessLogToSdCard(ServiceCtx context)
|
|
|
|
{
|
|
|
|
string message = ReadUtf8StringSend(context);
|
|
|
|
|
|
|
|
// FS ends each line with a newline. Remove it because Ryujinx logging adds its own newline
|
|
|
|
Logger.PrintAccessLog(LogClass.ServiceFs, message.TrimEnd('\n'));
|
2018-02-25 05:34:16 +01:00
|
|
|
|
|
|
|
return 0;
|
2018-04-06 06:01:52 +02:00
|
|
|
}
|
2018-09-09 00:04:26 +02:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
public void LoadSaveDataFileSystem(ServiceCtx context)
|
2018-09-09 00:04:26 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
SaveSpaceId saveSpaceId = (SaveSpaceId)context.RequestData.ReadInt64();
|
2018-09-09 00:04:26 +02:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
long titleId = context.RequestData.ReadInt64();
|
2018-09-09 00:04:26 +02:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
UInt128 userId = new UInt128(
|
|
|
|
context.RequestData.ReadInt64(),
|
|
|
|
context.RequestData.ReadInt64());
|
2018-09-09 00:04:26 +02:00
|
|
|
|
2019-06-01 02:31:10 +02: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);
|
|
|
|
LocalFileSystem fileSystem = new LocalFileSystem(savePath);
|
2018-11-18 20:37:41 +01:00
|
|
|
|
2019-06-01 02:31:10 +02:00
|
|
|
DirectorySaveDataFileSystem saveFileSystem = new DirectorySaveDataFileSystem(fileSystem);
|
|
|
|
|
|
|
|
MakeObject(context, new IFileSystem(saveFileSystem));
|
2018-11-18 20:37:41 +01:00
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private long OpenNsp(ServiceCtx context, string pfsPath)
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
2019-06-01 02:31:10 +02:00
|
|
|
LocalStorage storage = new LocalStorage(pfsPath, FileAccess.Read, FileMode.Open);
|
|
|
|
PartitionFileSystem nsp = new PartitionFileSystem(storage);
|
2018-11-18 20:37:41 +01:00
|
|
|
|
2019-01-05 01:41:49 +01:00
|
|
|
ImportTitleKeysFromNsp(nsp, context.Device.System.KeySet);
|
2019-06-01 02:31:10 +02:00
|
|
|
|
|
|
|
IFileSystem nspFileSystem = new IFileSystem(nsp);
|
2018-11-18 20:37:41 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
MakeObject(context, nspFileSystem);
|
2018-11-18 20:37:41 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-06-01 02:31:10 +02:00
|
|
|
private long OpenNcaFs(ServiceCtx context, string ncaPath, LibHac.Fs.IStorage ncaStorage)
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
2019-06-01 02:31:10 +02:00
|
|
|
Nca nca = new Nca(context.Device.System.KeySet, ncaStorage);
|
2018-11-18 20:37:41 +01:00
|
|
|
|
2019-06-01 02:31:10 +02:00
|
|
|
if (!nca.SectionExists(NcaSectionType.Data))
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
|
|
|
return MakeError(ErrorModule.Fs, FsErr.PartitionNotFound);
|
|
|
|
}
|
|
|
|
|
2019-06-01 02:31:10 +02:00
|
|
|
LibHac.Fs.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
|
|
|
|
|
|
|
|
MakeObject(context, new IFileSystem(fileSystem));
|
|
|
|
|
2018-11-18 20:37:41 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private long OpenFileSystemFromInternalFile(ServiceCtx context, string fullPath)
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
DirectoryInfo archivePath = new DirectoryInfo(fullPath).Parent;
|
2018-11-18 20:37:41 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
while (string.IsNullOrWhiteSpace(archivePath.Extension))
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
archivePath = archivePath.Parent;
|
2018-11-18 20:37:41 +01:00
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
if (archivePath.Extension == ".nsp" && File.Exists(archivePath.FullName))
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
FileStream pfsFile = new FileStream(
|
|
|
|
archivePath.FullName.TrimEnd(Path.DirectorySeparatorChar),
|
2018-11-18 20:37:41 +01:00
|
|
|
FileMode.Open,
|
|
|
|
FileAccess.Read);
|
|
|
|
|
2019-06-01 02:31:10 +02:00
|
|
|
PartitionFileSystem nsp = new PartitionFileSystem(pfsFile.AsStorage());
|
2018-09-09 00:04:26 +02:00
|
|
|
|
2019-01-05 01:41:49 +01:00
|
|
|
ImportTitleKeysFromNsp(nsp, context.Device.System.KeySet);
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
string filename = fullPath.Replace(archivePath.FullName, string.Empty).TrimStart('\\');
|
2018-09-09 00:04:26 +02:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
if (nsp.FileExists(filename))
|
2018-11-18 20:37:41 +01:00
|
|
|
{
|
2019-06-01 02:31:10 +02:00
|
|
|
return OpenNcaFs(context, fullPath, nsp.OpenFile(filename, OpenMode.Read).AsStorage());
|
2018-11-18 20:37:41 +01:00
|
|
|
}
|
|
|
|
}
|
2018-09-09 00:04:26 +02:00
|
|
|
|
2018-11-18 20:37:41 +01:00
|
|
|
return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist);
|
2018-09-09 00:04:26 +02:00
|
|
|
}
|
2019-01-05 01:41:49 +01:00
|
|
|
|
2019-06-01 02:31:10 +02:00
|
|
|
private void ImportTitleKeysFromNsp(LibHac.Fs.IFileSystem nsp, Keyset keySet)
|
2019-01-05 01:41:49 +01:00
|
|
|
{
|
2019-06-01 02:31:10 +02:00
|
|
|
foreach (LibHac.Fs.DirectoryEntry ticketEntry in nsp.EnumerateEntries("*.tik"))
|
2019-01-05 01:41:49 +01:00
|
|
|
{
|
2019-06-01 02:31:10 +02:00
|
|
|
Ticket ticket = new Ticket(nsp.OpenFile(ticketEntry.FullPath, OpenMode.Read).AsStream());
|
2019-01-05 01:41:49 +01:00
|
|
|
|
|
|
|
if (!keySet.TitleKeys.ContainsKey(ticket.RightsId))
|
|
|
|
{
|
|
|
|
keySet.TitleKeys.Add(ticket.RightsId, ticket.GetTitleKey(keySet));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-02-25 05:34:16 +01:00
|
|
|
}
|
|
|
|
}
|