cellUserInfo: Cleanup, notify about errors

This commit is contained in:
Raul Tambre 2016-04-09 13:03:53 +03:00
parent 97083ebba4
commit b073ead988
No known key found for this signature in database
GPG key ID: FC357D4861AC031E
2 changed files with 43 additions and 7 deletions

View file

@ -13,7 +13,9 @@ s32 cellUserInfoGetStat(u32 id, vm::ptr<CellUserInfoUserStat> stat)
cellUserInfo.warning("cellUserInfoGetStat(id=%d, stat=*0x%x)", id, stat);
if (id > CELL_SYSUTIL_USERID_MAX)
{
return CELL_USERINFO_ERROR_NOUSER;
}
if (id == CELL_SYSUTIL_USERID_CURRENT)
{
@ -22,15 +24,24 @@ s32 cellUserInfoGetStat(u32 id, vm::ptr<CellUserInfoUserStat> stat)
}
const std::string& path = vfs::get(fmt::format("/dev_hdd0/home/%08d/", id));
if (!fs::is_dir(path))
{
cellUserInfo.error("cellUserInfoGetStat(): CELL_USERINFO_ERROR_NOUSER. User %d doesn't exist. Did you delete the user folder?", id);
return CELL_USERINFO_ERROR_NOUSER;
}
const fs::file f(path + "localusername");
if (!f)
{
cellUserInfo.error("cellUserInfoGetStat(): CELL_USERINFO_ERROR_INTERNAL. Username for user %d doesn't exist. Did you delete the username file?", id);
return CELL_USERINFO_ERROR_INTERNAL;
}
stat->id = id;
strcpy_trunc(stat->name, f.to_string());
return CELL_OK;
}
@ -52,20 +63,31 @@ s32 cellUserInfoEnableOverlay()
return CELL_OK;
}
s32 cellUserInfoGetList(vm::ptr<u32> listNum, vm::ptr<CellUserInfoUserList> listBuf, vm::ptr<u32> currentUserId)
ppu_error_code cellUserInfoGetList(vm::ptr<u32> listNum, vm::ptr<CellUserInfoUserList> listBuf, vm::ptr<u32> currentUserId)
{
cellUserInfo.warning("cellUserInfoGetList(listNum=*0x%x, listBuf=*0x%x, currentUserId=*0x%x)", listNum, listBuf, currentUserId);
cellUserInfo.todo("cellUserInfoGetList(listNum=*0x%x, listBuf=*0x%x, currentUserId=*0x%x)", listNum, listBuf, currentUserId);
// If only listNum is NULL, an error will be returned
if (listBuf && !listNum)
{
return CELL_USERINFO_ERROR_PARAM;
}
if (listNum)
{
*listNum = 1;
}
if (listBuf)
{
listBuf->userId[0] = 1;
}
if (currentUserId)
{
// TODO: Properly set the current user ID here, once implemented
*currentUserId = 1;
}
return CELL_OK;
}

View file

@ -3,16 +3,30 @@
namespace vm { using namespace ps3; }
// Return Codes
enum
enum CellUserInfoError : s32
{
CELL_USERINFO_RET_OK = 0,
CELL_USERINFO_RET_CANCEL = 1,
CELL_USERINFO_ERROR_BUSY = 0x8002c301,
CELL_USERINFO_ERROR_INTERNAL = 0x8002c302,
CELL_USERINFO_ERROR_PARAM = 0x8002c303,
CELL_USERINFO_ERROR_NOUSER = 0x8002c304,
CELL_USERINFO_ERROR_BUSY = ERROR_CODE(0x8002c301),
CELL_USERINFO_ERROR_INTERNAL = ERROR_CODE(0x8002c302),
CELL_USERINFO_ERROR_PARAM = ERROR_CODE(0x8002c303),
CELL_USERINFO_ERROR_NOUSER = ERROR_CODE(0x8002c304),
};
template<>
inline const char* ppu_error_code::print(CellUserInfoError error)
{
switch (error)
{
STR_CASE(CELL_USERINFO_ERROR_BUSY);
STR_CASE(CELL_USERINFO_ERROR_INTERNAL);
STR_CASE(CELL_USERINFO_ERROR_PARAM);
STR_CASE(CELL_USERINFO_ERROR_NOUSER);
}
return nullptr;
}
// Enums
enum CellUserInfoParamSize
{