WFS: Implemented the GET_SIZE ioctl.
This commit is contained in:
parent
2f5ddf12a9
commit
49a4712f33
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "Core/IOS/WFS/WFSSRV.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -157,6 +158,28 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
|||
break;
|
||||
}
|
||||
|
||||
case IOCTL_WFS_GET_SIZE:
|
||||
{
|
||||
u16 fd = Memory::Read_U16(request.buffer_in);
|
||||
FileDescriptor* fd_obj = FindFileDescriptor(fd);
|
||||
if (fd_obj == nullptr)
|
||||
{
|
||||
ERROR_LOG(IOS, "IOCTL_WFS_GET_SIZE: invalid file descriptor %d", fd);
|
||||
return_error_code = WFS_EBADFD;
|
||||
break;
|
||||
}
|
||||
|
||||
u64 size = fd_obj->file.GetSize();
|
||||
u32 truncated_size = static_cast<u32>(size);
|
||||
INFO_LOG(IOS, "IOCTL_WFS_GET_SIZE(%d) -> %d", fd, truncated_size);
|
||||
if (size != truncated_size)
|
||||
{
|
||||
ERROR_LOG(IOS, "IOCTL_WFS_GET_SIZE: file %d too large (%" PRIu64 ")", fd, size);
|
||||
}
|
||||
Memory::Write_U32(truncated_size, request.buffer_out);
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTL_WFS_CLOSE:
|
||||
{
|
||||
u16 fd = Memory::Read_U16(request.buffer_in + 0x4);
|
||||
|
|
|
@ -61,6 +61,7 @@ private:
|
|||
IOCTL_WFS_DELETE = 0x15,
|
||||
IOCTL_WFS_GET_ATTRIBUTES = 0x17,
|
||||
IOCTL_WFS_OPEN = 0x1A,
|
||||
IOCTL_WFS_GET_SIZE = 0x1B,
|
||||
IOCTL_WFS_CLOSE = 0x1E,
|
||||
IOCTL_WFS_READ = 0x20,
|
||||
IOCTL_WFS_WRITE = 0x22,
|
||||
|
@ -70,6 +71,7 @@ private:
|
|||
|
||||
enum
|
||||
{
|
||||
WFS_EBADFD = -10026, // Invalid file descriptor.
|
||||
WFS_EEMPTY = -10028, // Directory is empty of iteration completed.
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue