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
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue