From 6f0cabb1c5351e27645959a30df0496c1d4d9122 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 28 Jan 2017 17:41:40 -0500 Subject: [PATCH 1/2] FileIO: Move GetFileStats code to its own function --- Source/Core/Core/IOS/FS/FileIO.cpp | 31 +++++++++++++++--------------- Source/Core/Core/IOS/FS/FileIO.h | 2 ++ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Source/Core/Core/IOS/FS/FileIO.cpp b/Source/Core/Core/IOS/FS/FileIO.cpp index 48dc4891c8..b9fa9f25e1 100644 --- a/Source/Core/Core/IOS/FS/FileIO.cpp +++ b/Source/Core/Core/IOS/FS/FileIO.cpp @@ -291,31 +291,18 @@ IPCCommandResult FileIO::Write(const ReadWriteRequest& request) IPCCommandResult FileIO::IOCtl(const IOCtlRequest& request) { DEBUG_LOG(IOS_FILEIO, "FileIO: IOCtl (Device=%s)", m_name.c_str()); - s32 return_value = IPC_SUCCESS; switch (request.request) { case ISFS_IOCTL_GETFILESTATS: - { - if (m_file->IsOpen()) - { - DEBUG_LOG(IOS_FILEIO, "File: %s, Length: %" PRIu64 ", Pos: %i", m_name.c_str(), - m_file->GetSize(), m_SeekPos); - Memory::Write_U32(static_cast(m_file->GetSize()), request.buffer_out); - Memory::Write_U32(m_SeekPos, request.buffer_out + 4); - } - else - { - return_value = FS_ENOENT; - } - } - break; + return GetFileStats(request); default: request.Log(GetDeviceName(), LogTypes::IOS_FILEIO, LogTypes::LERROR); + break; } - return GetDefaultReply(return_value); + return GetDefaultReply(IPC_SUCCESS); } void FileIO::PrepareForState(PointerWrap::Mode mode) @@ -338,6 +325,18 @@ void FileIO::DoState(PointerWrap& p) // Open it again OpenFile(); } + +IPCCommandResult FileIO::GetFileStats(const IOCtlRequest& request) +{ + if (!m_file->IsOpen()) + return GetDefaultReply(FS_ENOENT); + + DEBUG_LOG(IOS_FILEIO, "File: %s, Length: %" PRIu64 ", Pos: %i", m_name.c_str(), m_file->GetSize(), + m_SeekPos); + Memory::Write_U32(static_cast(m_file->GetSize()), request.buffer_out); + Memory::Write_U32(m_SeekPos, request.buffer_out + 4); + return GetDefaultReply(IPC_SUCCESS); +} } // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/FS/FileIO.h b/Source/Core/Core/IOS/FS/FileIO.h index edc192e418..feb8878892 100644 --- a/Source/Core/Core/IOS/FS/FileIO.h +++ b/Source/Core/Core/IOS/FS/FileIO.h @@ -70,6 +70,8 @@ private: ISFS_IOCTL_SHUTDOWN = 13 }; + IPCCommandResult GetFileStats(const IOCtlRequest& request); + u32 m_Mode = 0; u32 m_SeekPos = 0; From 4c31bfef76b332bfc879b572f00ba030749773a2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 28 Jan 2017 17:43:19 -0500 Subject: [PATCH 2/2] FileIO: Correct printf specifier in GetFileStats --- Source/Core/Core/IOS/FS/FileIO.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Core/IOS/FS/FileIO.cpp b/Source/Core/Core/IOS/FS/FileIO.cpp index b9fa9f25e1..2029055f84 100644 --- a/Source/Core/Core/IOS/FS/FileIO.cpp +++ b/Source/Core/Core/IOS/FS/FileIO.cpp @@ -331,7 +331,7 @@ IPCCommandResult FileIO::GetFileStats(const IOCtlRequest& request) if (!m_file->IsOpen()) return GetDefaultReply(FS_ENOENT); - DEBUG_LOG(IOS_FILEIO, "File: %s, Length: %" PRIu64 ", Pos: %i", m_name.c_str(), m_file->GetSize(), + DEBUG_LOG(IOS_FILEIO, "File: %s, Length: %" PRIu64 ", Pos: %u", m_name.c_str(), m_file->GetSize(), m_SeekPos); Memory::Write_U32(static_cast(m_file->GetSize()), request.buffer_out); Memory::Write_U32(m_SeekPos, request.buffer_out + 4);