2019-08-17 13:51:31 -04:00
|
|
|
#include <cstring>
|
2015-01-26 03:39:44 -05:00
|
|
|
#include "Iop_FileIoHandler2100.h"
|
|
|
|
#include "Iop_Ioman.h"
|
2025-03-11 12:48:26 -04:00
|
|
|
#include "Log.h"
|
2015-01-26 03:39:44 -05:00
|
|
|
|
|
|
|
#define LOG_NAME ("iop_fileio")
|
|
|
|
|
|
|
|
using namespace Iop;
|
|
|
|
|
|
|
|
CFileIoHandler2100::CFileIoHandler2100(CIoman* ioman)
|
2018-04-30 21:01:23 +01:00
|
|
|
: CHandler(ioman)
|
2015-01-26 03:39:44 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-09-13 11:16:16 -04:00
|
|
|
bool CFileIoHandler2100::Invoke(uint32 method, uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, uint8* ram)
|
2015-01-26 03:39:44 -05:00
|
|
|
{
|
|
|
|
switch(method)
|
|
|
|
{
|
|
|
|
case 0:
|
2018-04-30 21:01:23 +01:00
|
|
|
{
|
|
|
|
assert(retSize == 4);
|
|
|
|
auto command = reinterpret_cast<OPENCOMMAND*>(args);
|
|
|
|
*ret = m_ioman->Open(command->flags, command->fileName);
|
|
|
|
}
|
|
|
|
break;
|
2015-01-26 03:39:44 -05:00
|
|
|
case 1:
|
2018-04-30 21:01:23 +01:00
|
|
|
{
|
|
|
|
assert(retSize == 4);
|
|
|
|
auto command = reinterpret_cast<CLOSECOMMAND*>(args);
|
|
|
|
*ret = m_ioman->Close(command->fd);
|
|
|
|
}
|
|
|
|
break;
|
2015-01-26 03:39:44 -05:00
|
|
|
case 2:
|
2018-04-30 21:01:23 +01:00
|
|
|
{
|
|
|
|
assert(retSize == 4);
|
|
|
|
auto command = reinterpret_cast<READCOMMAND*>(args);
|
|
|
|
*ret = m_ioman->Read(command->fd, command->size, reinterpret_cast<void*>(ram + command->buffer));
|
|
|
|
}
|
|
|
|
break;
|
2015-01-26 03:39:44 -05:00
|
|
|
case 4:
|
2018-04-30 21:01:23 +01:00
|
|
|
{
|
|
|
|
assert(retSize == 4);
|
|
|
|
auto command = reinterpret_cast<SEEKCOMMAND*>(args);
|
|
|
|
*ret = m_ioman->Seek(command->fd, command->offset, command->whence);
|
|
|
|
}
|
|
|
|
break;
|
2015-01-26 03:39:44 -05:00
|
|
|
case 255:
|
2022-10-04 13:42:43 -04:00
|
|
|
//Init - Taken care of by owner (CFileIo)
|
2015-01-26 03:39:44 -05:00
|
|
|
break;
|
|
|
|
default:
|
2018-05-24 12:59:15 -04:00
|
|
|
CLog::GetInstance().Warn(LOG_NAME, "Unknown function (%d) called.\r\n", method);
|
2015-01-26 03:39:44 -05:00
|
|
|
break;
|
|
|
|
}
|
2019-09-13 11:16:16 -04:00
|
|
|
return true;
|
2015-01-26 03:39:44 -05:00
|
|
|
}
|