Catch HorizonResultException in IFileSystemProxy
This commit is contained in:
parent
8defbed035
commit
5d708792be
3 changed files with 80 additions and 38 deletions
|
@ -3,6 +3,7 @@ using LibHac.Fs;
|
|||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using static Ryujinx.HLE.HOS.ErrorCode;
|
||||
using static Ryujinx.HLE.Utilities.StringUtils;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.FspSrv
|
||||
|
@ -174,7 +175,14 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
{
|
||||
DirectoryEntryType entryType = _fileSystem.GetEntryType(name);
|
||||
|
||||
context.ResponseData.Write((int)entryType);
|
||||
if (entryType == DirectoryEntryType.Directory || entryType == DirectoryEntryType.File)
|
||||
{
|
||||
context.ResponseData.Write((int)entryType);
|
||||
}
|
||||
else
|
||||
{
|
||||
return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist);
|
||||
}
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
|
|
|
@ -126,17 +126,13 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
// OpenSaveDataFileSystem(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> saveDataFs
|
||||
public long OpenSaveDataFileSystem(ServiceCtx context)
|
||||
{
|
||||
LoadSaveDataFileSystem(context);
|
||||
|
||||
return 0;
|
||||
return LoadSaveDataFileSystem(context);
|
||||
}
|
||||
|
||||
// OpenSaveDataFileSystemBySystemSaveDataId(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> systemSaveDataFs
|
||||
public long OpenSaveDataFileSystemBySystemSaveDataId(ServiceCtx context)
|
||||
{
|
||||
LoadSaveDataFileSystem(context);
|
||||
|
||||
return 0;
|
||||
return LoadSaveDataFileSystem(context);
|
||||
}
|
||||
|
||||
// OpenDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> dataStorage
|
||||
|
@ -178,11 +174,18 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
|
||||
if (File.Exists(ncaPath))
|
||||
{
|
||||
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);
|
||||
try
|
||||
{
|
||||
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);
|
||||
|
||||
MakeObject(context, new IStorage(romfsStorage));
|
||||
MakeObject(context, new IStorage(romfsStorage));
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -229,7 +232,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
public void LoadSaveDataFileSystem(ServiceCtx context)
|
||||
public long LoadSaveDataFileSystem(ServiceCtx context)
|
||||
{
|
||||
SaveSpaceId saveSpaceId = (SaveSpaceId)context.RequestData.ReadInt64();
|
||||
|
||||
|
@ -241,39 +244,63 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
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);
|
||||
|
||||
DirectorySaveDataFileSystem saveFileSystem = new DirectorySaveDataFileSystem(fileSystem);
|
||||
try
|
||||
{
|
||||
LocalFileSystem fileSystem = new LocalFileSystem(savePath);
|
||||
|
||||
MakeObject(context, new IFileSystem(saveFileSystem));
|
||||
DirectorySaveDataFileSystem saveFileSystem = new DirectorySaveDataFileSystem(fileSystem);
|
||||
|
||||
MakeObject(context, new IFileSystem(saveFileSystem));
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private long OpenNsp(ServiceCtx context, string pfsPath)
|
||||
{
|
||||
LocalStorage storage = new LocalStorage(pfsPath, FileAccess.Read, FileMode.Open);
|
||||
PartitionFileSystem nsp = new PartitionFileSystem(storage);
|
||||
try
|
||||
{
|
||||
LocalStorage storage = new LocalStorage(pfsPath, FileAccess.Read, FileMode.Open);
|
||||
PartitionFileSystem nsp = new PartitionFileSystem(storage);
|
||||
|
||||
ImportTitleKeysFromNsp(nsp, context.Device.System.KeySet);
|
||||
|
||||
IFileSystem nspFileSystem = new IFileSystem(nsp);
|
||||
ImportTitleKeysFromNsp(nsp, context.Device.System.KeySet);
|
||||
|
||||
IFileSystem nspFileSystem = new IFileSystem(nsp);
|
||||
|
||||
MakeObject(context, nspFileSystem);
|
||||
MakeObject(context, nspFileSystem);
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private long OpenNcaFs(ServiceCtx context, string ncaPath, LibHac.Fs.IStorage ncaStorage)
|
||||
{
|
||||
Nca nca = new Nca(context.Device.System.KeySet, ncaStorage);
|
||||
|
||||
if (!nca.SectionExists(NcaSectionType.Data))
|
||||
try
|
||||
{
|
||||
return MakeError(ErrorModule.Fs, FsErr.PartitionNotFound);
|
||||
Nca nca = new Nca(context.Device.System.KeySet, ncaStorage);
|
||||
|
||||
if (!nca.SectionExists(NcaSectionType.Data))
|
||||
{
|
||||
return MakeError(ErrorModule.Fs, FsErr.PartitionNotFound);
|
||||
}
|
||||
|
||||
LibHac.Fs.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
|
||||
|
||||
MakeObject(context, new IFileSystem(fileSystem));
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
LibHac.Fs.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
|
||||
|
||||
MakeObject(context, new IFileSystem(fileSystem));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -294,15 +321,22 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
FileMode.Open,
|
||||
FileAccess.Read);
|
||||
|
||||
PartitionFileSystem nsp = new PartitionFileSystem(pfsFile.AsStorage());
|
||||
|
||||
ImportTitleKeysFromNsp(nsp, context.Device.System.KeySet);
|
||||
|
||||
string filename = fullPath.Replace(archivePath.FullName, string.Empty).TrimStart('\\');
|
||||
|
||||
if (nsp.FileExists(filename))
|
||||
try
|
||||
{
|
||||
return OpenNcaFs(context, fullPath, nsp.OpenFile(filename, OpenMode.Read).AsStorage());
|
||||
PartitionFileSystem nsp = new PartitionFileSystem(pfsFile.AsStorage());
|
||||
|
||||
ImportTitleKeysFromNsp(nsp, context.Device.System.KeySet);
|
||||
|
||||
string filename = fullPath.Replace(archivePath.FullName, string.Empty).TrimStart('\\');
|
||||
|
||||
if (nsp.FileExists(filename))
|
||||
{
|
||||
return OpenNcaFs(context, fullPath, nsp.OpenFile(filename, OpenMode.Read).AsStorage());
|
||||
}
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Concentus" Version="1.1.7" />
|
||||
<PackageReference Include="LibHac" Version="0.4.2--more-results.21" />
|
||||
<PackageReference Include="LibHac" Version="0.5.0" />
|
||||
<PackageReference Include="TimeZoneConverter.Posix" Version="2.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue