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 MakeFileSystem(Location location) return std::make_unique(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(-(static_cast(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 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(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.