Refactoring result codes (#731)
* refactoring result codes - Add a main enum who can handle some orphalin result codes and the default `ResultCode.Success` one. - Add sub-enum by services when it's needed. - Remove some empty line. - Recast all service calls to ResultCode. - Remove some unneeded static declaration. - Delete unused `NvHelper` class. * NvResult is back * Fix
This commit is contained in:
parent
4926f6523d
commit
4ad3936afd
147 changed files with 1413 additions and 1477 deletions
|
@ -9,4 +9,4 @@
|
|||
ContentData = 6,
|
||||
ApplicationPackage = 7
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
namespace Ryujinx.HLE.HOS.Services.FspSrv
|
||||
{
|
||||
static class FsErr
|
||||
{
|
||||
public const int PathDoesNotExist = 1;
|
||||
public const int PathAlreadyExists = 2;
|
||||
public const int PathAlreadyInUse = 7;
|
||||
public const int PartitionNotFound = 1001;
|
||||
public const int InvalidInput = 6001;
|
||||
}
|
||||
}
|
|
@ -20,7 +20,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
|
||||
[Command(0)]
|
||||
// Read() -> (u64 count, buffer<nn::fssrv::sf::IDirectoryEntry, 6, 0> entries)
|
||||
public long Read(ServiceCtx context)
|
||||
public ResultCode Read(ServiceCtx context)
|
||||
{
|
||||
long bufferPosition = context.Request.ReceiveBuff[0].Position;
|
||||
long bufferLen = context.Request.ReceiveBuff[0].Size;
|
||||
|
@ -41,12 +41,12 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
context.ResponseData.Write((long)readCount);
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
private void WriteDirectoryEntry(ServiceCtx context, long position, LibHac.Fs.DirectoryEntry entry)
|
||||
|
@ -67,7 +67,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
|
||||
[Command(1)]
|
||||
// GetEntryCount() -> u64
|
||||
public long GetEntryCount(ServiceCtx context)
|
||||
public ResultCode GetEntryCount(ServiceCtx context)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -75,10 +75,10 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
|
||||
[Command(0)]
|
||||
// Read(u32 readOption, u64 offset, u64 size) -> (u64 out_size, buffer<u8, 0x46, 0> out_buf)
|
||||
public long Read(ServiceCtx context)
|
||||
public ResultCode Read(ServiceCtx context)
|
||||
{
|
||||
long position = context.Request.ReceiveBuff[0].Position;
|
||||
|
||||
|
@ -34,19 +34,19 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
context.Memory.WriteBytes(position, data);
|
||||
|
||||
context.ResponseData.Write((long)readSize);
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(1)]
|
||||
// Write(u32 writeOption, u64 offset, u64 size, buffer<u8, 0x45, 0>)
|
||||
public long Write(ServiceCtx context)
|
||||
public ResultCode Write(ServiceCtx context)
|
||||
{
|
||||
long position = context.Request.SendBuff[0].Position;
|
||||
|
||||
|
@ -64,15 +64,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(2)]
|
||||
// Flush()
|
||||
public long Flush(ServiceCtx context)
|
||||
public ResultCode Flush(ServiceCtx context)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -80,15 +80,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(3)]
|
||||
// SetSize(u64 size)
|
||||
public long SetSize(ServiceCtx context)
|
||||
public ResultCode SetSize(ServiceCtx context)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -98,15 +98,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(4)]
|
||||
// GetSize() -> u64 fileSize
|
||||
public long GetSize(ServiceCtx context)
|
||||
public ResultCode GetSize(ServiceCtx context)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -114,10 +114,10 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using LibHac;
|
||||
using LibHac.Fs;
|
||||
|
||||
using static Ryujinx.HLE.HOS.ErrorCode;
|
||||
using static Ryujinx.HLE.Utilities.StringUtils;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.FspSrv
|
||||
|
@ -17,7 +16,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
|
||||
[Command(0)]
|
||||
// CreateFile(u32 createOption, u64 size, buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public long CreateFile(ServiceCtx context)
|
||||
public ResultCode CreateFile(ServiceCtx context)
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
|
@ -32,15 +31,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(1)]
|
||||
// DeleteFile(buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public long DeleteFile(ServiceCtx context)
|
||||
public ResultCode DeleteFile(ServiceCtx context)
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
|
@ -50,15 +49,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(2)]
|
||||
// CreateDirectory(buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public long CreateDirectory(ServiceCtx context)
|
||||
public ResultCode CreateDirectory(ServiceCtx context)
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
|
@ -68,15 +67,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(3)]
|
||||
// DeleteDirectory(buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public long DeleteDirectory(ServiceCtx context)
|
||||
public ResultCode DeleteDirectory(ServiceCtx context)
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
|
@ -86,15 +85,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(4)]
|
||||
// DeleteDirectoryRecursively(buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public long DeleteDirectoryRecursively(ServiceCtx context)
|
||||
public ResultCode DeleteDirectoryRecursively(ServiceCtx context)
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
|
@ -104,15 +103,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(5)]
|
||||
// RenameFile(buffer<bytes<0x301>, 0x19, 0x301> oldPath, buffer<bytes<0x301>, 0x19, 0x301> newPath)
|
||||
public long RenameFile(ServiceCtx context)
|
||||
public ResultCode RenameFile(ServiceCtx context)
|
||||
{
|
||||
string oldName = ReadUtf8String(context, 0);
|
||||
string newName = ReadUtf8String(context, 1);
|
||||
|
@ -123,15 +122,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(6)]
|
||||
// RenameDirectory(buffer<bytes<0x301>, 0x19, 0x301> oldPath, buffer<bytes<0x301>, 0x19, 0x301> newPath)
|
||||
public long RenameDirectory(ServiceCtx context)
|
||||
public ResultCode RenameDirectory(ServiceCtx context)
|
||||
{
|
||||
string oldName = ReadUtf8String(context, 0);
|
||||
string newName = ReadUtf8String(context, 1);
|
||||
|
@ -142,15 +141,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(7)]
|
||||
// GetEntryType(buffer<bytes<0x301>, 0x19, 0x301> path) -> nn::fssrv::sf::DirectoryEntryType
|
||||
public long GetEntryType(ServiceCtx context)
|
||||
public ResultCode GetEntryType(ServiceCtx context)
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
|
@ -164,20 +163,20 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
else
|
||||
{
|
||||
return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist);
|
||||
return ResultCode.PathDoesNotExist;
|
||||
}
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(8)]
|
||||
// OpenFile(u32 mode, buffer<bytes<0x301>, 0x19, 0x301> path) -> object<nn::fssrv::sf::IFile> file
|
||||
public long OpenFile(ServiceCtx context)
|
||||
public ResultCode OpenFile(ServiceCtx context)
|
||||
{
|
||||
OpenMode mode = (OpenMode)context.RequestData.ReadInt32();
|
||||
|
||||
|
@ -193,15 +192,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(9)]
|
||||
// OpenDirectory(u32 filter_flags, buffer<bytes<0x301>, 0x19, 0x301> path) -> object<nn::fssrv::sf::IDirectory> directory
|
||||
public long OpenDirectory(ServiceCtx context)
|
||||
public ResultCode OpenDirectory(ServiceCtx context)
|
||||
{
|
||||
OpenDirectoryMode mode = (OpenDirectoryMode)context.RequestData.ReadInt32();
|
||||
|
||||
|
@ -217,15 +216,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(10)]
|
||||
// Commit()
|
||||
public long Commit(ServiceCtx context)
|
||||
public ResultCode Commit(ServiceCtx context)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -233,15 +232,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(11)]
|
||||
// GetFreeSpaceSize(buffer<bytes<0x301>, 0x19, 0x301> path) -> u64 totalFreeSpace
|
||||
public long GetFreeSpaceSize(ServiceCtx context)
|
||||
public ResultCode GetFreeSpaceSize(ServiceCtx context)
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
|
@ -251,15 +250,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(12)]
|
||||
// GetTotalSpaceSize(buffer<bytes<0x301>, 0x19, 0x301> path) -> u64 totalSize
|
||||
public long GetTotalSpaceSize(ServiceCtx context)
|
||||
public ResultCode GetTotalSpaceSize(ServiceCtx context)
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
|
@ -269,15 +268,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(13)]
|
||||
// CleanDirectoryRecursively(buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public long CleanDirectoryRecursively(ServiceCtx context)
|
||||
public ResultCode CleanDirectoryRecursively(ServiceCtx context)
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
|
@ -287,15 +286,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(14)]
|
||||
// GetFileTimeStampRaw(buffer<bytes<0x301>, 0x19, 0x301> path) -> bytes<0x20> timestamp
|
||||
public long GetFileTimeStampRaw(ServiceCtx context)
|
||||
public ResultCode GetFileTimeStampRaw(ServiceCtx context)
|
||||
{
|
||||
string name = ReadUtf8String(context);
|
||||
|
||||
|
@ -316,10 +315,10 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,6 @@ using Ryujinx.HLE.Utilities;
|
|||
using System.IO;
|
||||
|
||||
using static Ryujinx.HLE.FileSystem.VirtualFileSystem;
|
||||
using static Ryujinx.HLE.HOS.ErrorCode;
|
||||
using static Ryujinx.HLE.Utilities.StringUtils;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.FspSrv
|
||||
|
@ -20,15 +19,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
|
||||
[Command(1)]
|
||||
// Initialize(u64, pid)
|
||||
public long Initialize(ServiceCtx context)
|
||||
public ResultCode Initialize(ServiceCtx context)
|
||||
{
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(8)]
|
||||
// OpenFileSystemWithId(nn::fssrv::sf::FileSystemType filesystem_type, nn::ApplicationId tid, buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
// -> object<nn::fssrv::sf::IFileSystem> contentFs
|
||||
public long OpenFileSystemWithId(ServiceCtx context)
|
||||
public ResultCode OpenFileSystemWithId(ServiceCtx context)
|
||||
{
|
||||
FileSystemType fileSystemType = (FileSystemType)context.RequestData.ReadInt32();
|
||||
long titleId = context.RequestData.ReadInt64();
|
||||
|
@ -42,7 +41,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return OpenFileSystemFromInternalFile(context, fullPath);
|
||||
}
|
||||
|
||||
return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist);
|
||||
return ResultCode.PathDoesNotExist;
|
||||
}
|
||||
|
||||
FileStream fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read);
|
||||
|
@ -57,12 +56,12 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return OpenNsp(context, fullPath);
|
||||
}
|
||||
|
||||
return MakeError(ErrorModule.Fs, FsErr.InvalidInput);
|
||||
return ResultCode.InvalidInput;
|
||||
}
|
||||
|
||||
[Command(11)]
|
||||
// OpenBisFileSystem(nn::fssrv::sf::Partition partitionID, buffer<bytes<0x301>, 0x19, 0x301>) -> object<nn::fssrv::sf::IFileSystem> Bis
|
||||
public long OpenBisFileSystem(ServiceCtx context)
|
||||
public ResultCode OpenBisFileSystem(ServiceCtx context)
|
||||
{
|
||||
int bisPartitionId = context.RequestData.ReadInt32();
|
||||
string partitionString = ReadUtf8String(context);
|
||||
|
@ -81,7 +80,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
bisPartitionPath = UserNandPath;
|
||||
break;
|
||||
default:
|
||||
return MakeError(ErrorModule.Fs, FsErr.InvalidInput);
|
||||
return ResultCode.InvalidInput;
|
||||
}
|
||||
|
||||
string fullPath = context.Device.FileSystem.GetFullPartitionPath(bisPartitionPath);
|
||||
|
@ -90,12 +89,12 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
|
||||
MakeObject(context, new IFileSystem(fileSystem));
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(18)]
|
||||
// OpenSdCardFileSystem() -> object<nn::fssrv::sf::IFileSystem>
|
||||
public long OpenSdCardFileSystem(ServiceCtx context)
|
||||
public ResultCode OpenSdCardFileSystem(ServiceCtx context)
|
||||
{
|
||||
string sdCardPath = context.Device.FileSystem.GetSdCardPath();
|
||||
|
||||
|
@ -103,26 +102,26 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
|
||||
MakeObject(context, new IFileSystem(fileSystem));
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(51)]
|
||||
// OpenSaveDataFileSystem(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> saveDataFs
|
||||
public long OpenSaveDataFileSystem(ServiceCtx context)
|
||||
public ResultCode OpenSaveDataFileSystem(ServiceCtx context)
|
||||
{
|
||||
return LoadSaveDataFileSystem(context);
|
||||
}
|
||||
|
||||
[Command(52)]
|
||||
// OpenSaveDataFileSystemBySystemSaveDataId(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> systemSaveDataFs
|
||||
public long OpenSaveDataFileSystemBySystemSaveDataId(ServiceCtx context)
|
||||
public ResultCode OpenSaveDataFileSystemBySystemSaveDataId(ServiceCtx context)
|
||||
{
|
||||
return LoadSaveDataFileSystem(context);
|
||||
}
|
||||
|
||||
[Command(200)]
|
||||
// OpenDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> dataStorage
|
||||
public long OpenDataStorageByCurrentProcess(ServiceCtx context)
|
||||
public ResultCode OpenDataStorageByCurrentProcess(ServiceCtx context)
|
||||
{
|
||||
MakeObject(context, new IStorage(context.Device.FileSystem.RomFs.AsStorage()));
|
||||
|
||||
|
@ -131,7 +130,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
|
||||
[Command(202)]
|
||||
// OpenDataStorageByDataId(u8 storageId, nn::ApplicationId tid) -> object<nn::fssrv::sf::IStorage> dataStorage
|
||||
public long OpenDataStorageByDataId(ServiceCtx context)
|
||||
public ResultCode OpenDataStorageByDataId(ServiceCtx context)
|
||||
{
|
||||
StorageId storageId = (StorageId)context.RequestData.ReadByte();
|
||||
byte[] padding = context.RequestData.ReadBytes(7);
|
||||
|
@ -171,10 +170,10 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -192,37 +191,37 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
|
||||
[Command(203)]
|
||||
// OpenPatchDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage>
|
||||
public long OpenPatchDataStorageByCurrentProcess(ServiceCtx context)
|
||||
public ResultCode OpenPatchDataStorageByCurrentProcess(ServiceCtx context)
|
||||
{
|
||||
MakeObject(context, new IStorage(context.Device.FileSystem.RomFs.AsStorage()));
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(1005)]
|
||||
// GetGlobalAccessLogMode() -> u32 logMode
|
||||
public long GetGlobalAccessLogMode(ServiceCtx context)
|
||||
public ResultCode GetGlobalAccessLogMode(ServiceCtx context)
|
||||
{
|
||||
int mode = context.Device.System.GlobalAccessLogMode;
|
||||
|
||||
context.ResponseData.Write(mode);
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(1006)]
|
||||
// OutputAccessLogToSdCard(buffer<bytes, 5> log_text)
|
||||
public long OutputAccessLogToSdCard(ServiceCtx context)
|
||||
public ResultCode 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'));
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
public long LoadSaveDataFileSystem(ServiceCtx context)
|
||||
public ResultCode LoadSaveDataFileSystem(ServiceCtx context)
|
||||
{
|
||||
SaveSpaceId saveSpaceId = (SaveSpaceId)context.RequestData.ReadInt64();
|
||||
|
||||
|
@ -244,13 +243,13 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
private long OpenNsp(ServiceCtx context, string pfsPath)
|
||||
private ResultCode OpenNsp(ServiceCtx context, string pfsPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -265,13 +264,13 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
private long OpenNcaFs(ServiceCtx context, string ncaPath, LibHac.Fs.IStorage ncaStorage)
|
||||
private ResultCode OpenNcaFs(ServiceCtx context, string ncaPath, LibHac.Fs.IStorage ncaStorage)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -279,7 +278,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
|
||||
if (!nca.SectionExists(NcaSectionType.Data))
|
||||
{
|
||||
return MakeError(ErrorModule.Fs, FsErr.PartitionNotFound);
|
||||
return ResultCode.PartitionNotFound;
|
||||
}
|
||||
|
||||
LibHac.Fs.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
|
||||
|
@ -288,13 +287,13 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
private long OpenFileSystemFromInternalFile(ServiceCtx context, string fullPath)
|
||||
private ResultCode OpenFileSystemFromInternalFile(ServiceCtx context, string fullPath)
|
||||
{
|
||||
DirectoryInfo archivePath = new DirectoryInfo(fullPath).Parent;
|
||||
|
||||
|
@ -325,11 +324,11 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
}
|
||||
|
||||
return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist);
|
||||
return ResultCode.PathDoesNotExist;
|
||||
}
|
||||
|
||||
private void ImportTitleKeysFromNsp(LibHac.Fs.IFileSystem nsp, Keyset keySet)
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
|
||||
[Command(0)]
|
||||
// Read(u64 offset, u64 length) -> buffer<u8, 0x46, 0> buffer
|
||||
public long Read(ServiceCtx context)
|
||||
public ResultCode Read(ServiceCtx context)
|
||||
{
|
||||
long offset = context.RequestData.ReadInt64();
|
||||
long size = context.RequestData.ReadInt64();
|
||||
|
@ -37,18 +37,18 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
context.Memory.WriteBytes(buffDesc.Position, data);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[Command(4)]
|
||||
// GetSize() -> u64 size
|
||||
public long GetSize(ServiceCtx context)
|
||||
public ResultCode GetSize(ServiceCtx context)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -56,10 +56,10 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
return ex.ResultValue.Value;
|
||||
return (ResultCode)ex.ResultValue.Value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ResultCode.Success;
|
||||
}
|
||||
}
|
||||
}
|
16
Ryujinx.HLE/HOS/Services/FspSrv/ResultCode.cs
Normal file
16
Ryujinx.HLE/HOS/Services/FspSrv/ResultCode.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
namespace Ryujinx.HLE.HOS.Services.FspSrv
|
||||
{
|
||||
enum ResultCode
|
||||
{
|
||||
ModuleId = 2,
|
||||
ErrorCodeShift = 9,
|
||||
|
||||
Success = 0,
|
||||
|
||||
PathDoesNotExist = (1 << ErrorCodeShift) | ModuleId,
|
||||
PathAlreadyExists = (2 << ErrorCodeShift) | ModuleId,
|
||||
PathAlreadyInUse = (7 << ErrorCodeShift) | ModuleId,
|
||||
PartitionNotFound = (1001 << ErrorCodeShift) | ModuleId,
|
||||
InvalidInput = (6001 << ErrorCodeShift) | ModuleId
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue