summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2018-05-06 17:21:05 +0200
committerLéo Lam <leo@innovatetechnologi.es>2018-05-06 22:08:31 +0200
commit5dbf6cd0c98be721dbabe204a02ae0a481b44e59 (patch)
tree96dc66f6c0e51f7c36afe87bdb19ee51c6716153 /Source/Core
parentecb5c97b4dcccbf4cdf4c08890169ff770400cd1 (diff)
IOS/FS: Make ConvertResult usable from ES
ES makes extensive use of FS and most of the time returns its error codes directly.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/IOS/FS/FileSystem.cpp10
-rw-r--r--Source/Core/Core/IOS/FS/FileSystem.h12
-rw-r--r--Source/Core/Core/IOS/FS/FileSystemProxy.cpp7
3 files changed, 20 insertions, 9 deletions
diff --git a/Source/Core/Core/IOS/FS/FileSystem.cpp b/Source/Core/Core/IOS/FS/FileSystem.cpp
index c6db165002..e62c6bcc6b 100644
--- a/Source/Core/Core/IOS/FS/FileSystem.cpp
+++ b/Source/Core/Core/IOS/FS/FileSystem.cpp
@@ -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}
{
}
diff --git a/Source/Core/Core/IOS/FS/FileSystem.h b/Source/Core/Core/IOS/FS/FileSystem.h
index 42edb14cdf..a53cd36ac9 100644
--- a/Source/Core/Core/IOS/FS/FileSystem.h
+++ b/Source/Core/Core/IOS/FS/FileSystem.h
@@ -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
diff --git a/Source/Core/Core/IOS/FS/FileSystemProxy.cpp b/Source/Core/Core/IOS/FS/FileSystemProxy.cpp
index 587577d497..2fbcee6794 100644
--- a/Source/Core/Core/IOS/FS/FileSystemProxy.cpp
+++ b/Source/Core/Core/IOS/FS/FileSystemProxy.cpp
@@ -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.