diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2017-08-06 22:19:08 +0200 |
|---|---|---|
| committer | Pierre Bourdon <delroth@gmail.com> | 2017-08-15 22:35:45 +0200 |
| commit | 397f5e54e0472b0f2e348dcdb648adfbeef8ba3a (patch) | |
| tree | 732551b80a3ffacde9efc5a8e68ba4526bda36d0 /Source | |
| parent | 49a4712f33f9362c0ee92d23ecc3454afa5e1f62 (diff) | |
WFS: Implement READ_ABSOLUTE (merged with READ implementation).
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/Core/IOS/WFS/WFSSRV.cpp | 23 | ||||
| -rw-r--r-- | Source/Core/Core/IOS/WFS/WFSSRV.h | 1 |
2 files changed, 19 insertions, 5 deletions
diff --git a/Source/Core/Core/IOS/WFS/WFSSRV.cpp b/Source/Core/Core/IOS/WFS/WFSSRV.cpp index a2601f3422..0a76d6e482 100644 --- a/Source/Core/Core/IOS/WFS/WFSSRV.cpp +++ b/Source/Core/Core/IOS/WFS/WFSSRV.cpp @@ -189,26 +189,39 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request) } case IOCTL_WFS_READ: + case IOCTL_WFS_READ_ABSOLUTE: { u32 addr = Memory::Read_U32(request.buffer_in); + u32 position = Memory::Read_U32(request.buffer_in + 4); // Only for absolute. u16 fd = Memory::Read_U16(request.buffer_in + 0xC); u32 size = Memory::Read_U32(request.buffer_in + 8); + bool absolute = request.request == IOCTL_WFS_READ_ABSOLUTE; + FileDescriptor* fd_obj = FindFileDescriptor(fd); if (fd_obj == nullptr) { ERROR_LOG(IOS, "IOCTL_WFS_READ: invalid file descriptor %d", fd); - return_error_code = -1; // TODO(wfs): proper error code. + return_error_code = WFS_EBADFD; break; } + u64 previous_position = fd_obj->file.Tell(); + if (absolute) + { + fd_obj->file.Seek(position, SEEK_SET); + } size_t read_bytes; - if (!fd_obj->file.ReadArray(Memory::GetPointer(addr), size, &read_bytes)) + fd_obj->file.ReadArray(Memory::GetPointer(addr), size, &read_bytes); + // TODO(wfs): Handle read errors. + if (absolute) { - return_error_code = -1; // TODO(wfs): proper error code. - break; + fd_obj->file.Seek(previous_position, SEEK_SET); + } + else + { + fd_obj->position += read_bytes; } - fd_obj->position += read_bytes; INFO_LOG(IOS, "IOCTL_WFS_READ: read %zd bytes from FD %d (%s)", read_bytes, fd, fd_obj->path.c_str()); diff --git a/Source/Core/Core/IOS/WFS/WFSSRV.h b/Source/Core/Core/IOS/WFS/WFSSRV.h index 72b051f87a..cba30037a1 100644 --- a/Source/Core/Core/IOS/WFS/WFSSRV.h +++ b/Source/Core/Core/IOS/WFS/WFSSRV.h @@ -67,6 +67,7 @@ private: IOCTL_WFS_WRITE = 0x22, IOCTL_WFS_ATTACH_DETACH = 0x2d, IOCTL_WFS_ATTACH_DETACH_2 = 0x2e, + IOCTL_WFS_READ_ABSOLUTE = 0x48, }; enum |
