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 Ryujinx.HLE.HOS.Ipc;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
using static Ryujinx.HLE.HOS.ErrorCode;
|
||||||
using static Ryujinx.HLE.Utilities.StringUtils;
|
using static Ryujinx.HLE.Utilities.StringUtils;
|
||||||
|
|
||||||
namespace Ryujinx.HLE.HOS.Services.FspSrv
|
namespace Ryujinx.HLE.HOS.Services.FspSrv
|
||||||
|
@ -174,8 +175,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
||||||
{
|
{
|
||||||
DirectoryEntryType entryType = _fileSystem.GetEntryType(name);
|
DirectoryEntryType entryType = _fileSystem.GetEntryType(name);
|
||||||
|
|
||||||
|
if (entryType == DirectoryEntryType.Directory || entryType == DirectoryEntryType.File)
|
||||||
|
{
|
||||||
context.ResponseData.Write((int)entryType);
|
context.ResponseData.Write((int)entryType);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist);
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (HorizonResultException ex)
|
catch (HorizonResultException ex)
|
||||||
{
|
{
|
||||||
return ex.ResultValue.Value;
|
return ex.ResultValue.Value;
|
||||||
|
|
|
@ -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
|
// OpenSaveDataFileSystem(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> saveDataFs
|
||||||
public long OpenSaveDataFileSystem(ServiceCtx context)
|
public long OpenSaveDataFileSystem(ServiceCtx context)
|
||||||
{
|
{
|
||||||
LoadSaveDataFileSystem(context);
|
return LoadSaveDataFileSystem(context);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenSaveDataFileSystemBySystemSaveDataId(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> systemSaveDataFs
|
// OpenSaveDataFileSystemBySystemSaveDataId(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> systemSaveDataFs
|
||||||
public long OpenSaveDataFileSystemBySystemSaveDataId(ServiceCtx context)
|
public long OpenSaveDataFileSystemBySystemSaveDataId(ServiceCtx context)
|
||||||
{
|
{
|
||||||
LoadSaveDataFileSystem(context);
|
return LoadSaveDataFileSystem(context);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> dataStorage
|
// OpenDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> dataStorage
|
||||||
|
@ -177,12 +173,19 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
||||||
string ncaPath = installPath;
|
string ncaPath = installPath;
|
||||||
|
|
||||||
if (File.Exists(ncaPath))
|
if (File.Exists(ncaPath))
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
LibHac.Fs.IStorage ncaStorage = new LocalStorage(ncaPath, FileAccess.Read, FileMode.Open);
|
LibHac.Fs.IStorage ncaStorage = new LocalStorage(ncaPath, FileAccess.Read, FileMode.Open);
|
||||||
Nca nca = new Nca(context.Device.System.KeySet, ncaStorage);
|
Nca nca = new Nca(context.Device.System.KeySet, ncaStorage);
|
||||||
LibHac.Fs.IStorage romfsStorage = nca.OpenStorage(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -229,7 +232,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadSaveDataFileSystem(ServiceCtx context)
|
public long LoadSaveDataFileSystem(ServiceCtx context)
|
||||||
{
|
{
|
||||||
SaveSpaceId saveSpaceId = (SaveSpaceId)context.RequestData.ReadInt64();
|
SaveSpaceId saveSpaceId = (SaveSpaceId)context.RequestData.ReadInt64();
|
||||||
|
|
||||||
|
@ -241,14 +244,26 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
||||||
SaveDataType saveDataType = (SaveDataType)context.RequestData.ReadByte();
|
SaveDataType saveDataType = (SaveDataType)context.RequestData.ReadByte();
|
||||||
SaveInfo saveInfo = new SaveInfo(titleId, saveId, saveDataType, userId, saveSpaceId);
|
SaveInfo saveInfo = new SaveInfo(titleId, saveId, saveDataType, userId, saveSpaceId);
|
||||||
string savePath = context.Device.FileSystem.GetGameSavePath(saveInfo, context);
|
string savePath = context.Device.FileSystem.GetGameSavePath(saveInfo, context);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
LocalFileSystem fileSystem = new LocalFileSystem(savePath);
|
LocalFileSystem fileSystem = new LocalFileSystem(savePath);
|
||||||
|
|
||||||
DirectorySaveDataFileSystem saveFileSystem = new DirectorySaveDataFileSystem(fileSystem);
|
DirectorySaveDataFileSystem saveFileSystem = new DirectorySaveDataFileSystem(fileSystem);
|
||||||
|
|
||||||
MakeObject(context, new IFileSystem(saveFileSystem));
|
MakeObject(context, new IFileSystem(saveFileSystem));
|
||||||
}
|
}
|
||||||
|
catch (HorizonResultException ex)
|
||||||
|
{
|
||||||
|
return ex.ResultValue.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
private long OpenNsp(ServiceCtx context, string pfsPath)
|
private long OpenNsp(ServiceCtx context, string pfsPath)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
LocalStorage storage = new LocalStorage(pfsPath, FileAccess.Read, FileMode.Open);
|
LocalStorage storage = new LocalStorage(pfsPath, FileAccess.Read, FileMode.Open);
|
||||||
PartitionFileSystem nsp = new PartitionFileSystem(storage);
|
PartitionFileSystem nsp = new PartitionFileSystem(storage);
|
||||||
|
@ -258,11 +273,18 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
||||||
IFileSystem nspFileSystem = new IFileSystem(nsp);
|
IFileSystem nspFileSystem = new IFileSystem(nsp);
|
||||||
|
|
||||||
MakeObject(context, nspFileSystem);
|
MakeObject(context, nspFileSystem);
|
||||||
|
}
|
||||||
|
catch (HorizonResultException ex)
|
||||||
|
{
|
||||||
|
return ex.ResultValue.Value;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long OpenNcaFs(ServiceCtx context, string ncaPath, LibHac.Fs.IStorage ncaStorage)
|
private long OpenNcaFs(ServiceCtx context, string ncaPath, LibHac.Fs.IStorage ncaStorage)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Nca nca = new Nca(context.Device.System.KeySet, ncaStorage);
|
Nca nca = new Nca(context.Device.System.KeySet, ncaStorage);
|
||||||
|
|
||||||
|
@ -274,6 +296,11 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
||||||
LibHac.Fs.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
|
LibHac.Fs.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
|
||||||
|
|
||||||
MakeObject(context, new IFileSystem(fileSystem));
|
MakeObject(context, new IFileSystem(fileSystem));
|
||||||
|
}
|
||||||
|
catch (HorizonResultException ex)
|
||||||
|
{
|
||||||
|
return ex.ResultValue.Value;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -294,6 +321,8 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
||||||
FileMode.Open,
|
FileMode.Open,
|
||||||
FileAccess.Read);
|
FileAccess.Read);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
PartitionFileSystem nsp = new PartitionFileSystem(pfsFile.AsStorage());
|
PartitionFileSystem nsp = new PartitionFileSystem(pfsFile.AsStorage());
|
||||||
|
|
||||||
ImportTitleKeysFromNsp(nsp, context.Device.System.KeySet);
|
ImportTitleKeysFromNsp(nsp, context.Device.System.KeySet);
|
||||||
|
@ -305,6 +334,11 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
||||||
return OpenNcaFs(context, fullPath, nsp.OpenFile(filename, OpenMode.Read).AsStorage());
|
return OpenNcaFs(context, fullPath, nsp.OpenFile(filename, OpenMode.Read).AsStorage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (HorizonResultException ex)
|
||||||
|
{
|
||||||
|
return ex.ResultValue.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist);
|
return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Concentus" Version="1.1.7" />
|
<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" />
|
<PackageReference Include="TimeZoneConverter.Posix" Version="2.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue