Permalink
Browse files

IOS/FS: Make ConvertResult usable from ES

ES makes extensive use of FS and most of the time returns its error
codes directly.
  • Loading branch information...
leoetlino committed May 6, 2018
1 parent ecb5c97 commit 5dbf6cd0c98be721dbabe204a02ae0a481b44e59
@@ -6,6 +6,7 @@
#include "Common/Assert.h"
#include "Common/FileUtil.h"
#include "Core/IOS/Device.h"
#include "Core/IOS/FS/HostBackend/FS.h"
namespace IOS::HLE::FS
@@ -17,6 +18,15 @@ std::unique_ptr<FileSystem> MakeFileSystem(Location location)
return std::make_unique<HostFileSystem>(nand_root);
}
IOS::HLE::ReturnCode ConvertResult(ResultCode code)
{
if (code == ResultCode::Success)
return IPC_SUCCESS;
// FS error codes start at -100. Since result codes in the enum are listed in the same way
// as the IOS codes, we just need to return -100-code.
return static_cast<ReturnCode>(-(static_cast<s32>(code) + 100));
}
FileHandle::FileHandle(FileSystem* fs, Fd fd) : m_fs{fs}, m_fd{fd}
{
}
@@ -14,7 +14,11 @@
class PointerWrap;
namespace IOS::HLE::FS
namespace IOS::HLE
{
enum ReturnCode : s32;
namespace FS
{
enum class ResultCode
{
@@ -218,4 +222,8 @@ enum class Location
std::unique_ptr<FileSystem> MakeFileSystem(Location location = Location::Session);
} // namespace IOS::HLE::FS
/// Convert a FS result code to an IOS error code.
IOS::HLE::ReturnCode ConvertResult(ResultCode code);
} // namespace FS
} // namespace IOS::HLE
@@ -23,13 +23,6 @@ namespace Device
{
using namespace IOS::HLE::FS;
static s32 ConvertResult(ResultCode code)
{
if (code == ResultCode::Success)
return IPC_SUCCESS;
return -(static_cast<s32>(code) + 100);
}
static IPCCommandResult GetFSReply(s32 return_value, u64 extra_tb_ticks = 0)
{
// According to hardware tests, FS takes at least 2700 TB ticks to reply to commands.

0 comments on commit 5dbf6cd

Please sign in to comment.