mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-06 07:12:14 +01:00
[orbis-kernel] sys_stat: check for dirs
This commit is contained in:
parent
ebb6c58199
commit
dee73342ac
|
|
@ -1,3 +1,5 @@
|
|||
#include "orbis/utils/Logs.hpp"
|
||||
#include "stat.hpp"
|
||||
#include "sys/sysproto.hpp"
|
||||
|
||||
orbis::SysResult orbis::sys_getdtablesize(Thread *thread) {
|
||||
|
|
@ -24,6 +26,7 @@ orbis::SysResult orbis::sys_closefrom(Thread *thread, sint lowfd) {
|
|||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_fstat(Thread *thread, sint fd, ptr<Stat> ub) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, fd, ub);
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_nfstat(Thread *thread, sint fd,
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@ orbis::SysResult orbis::sys_eaccess(Thread *thread, ptr<char> path,
|
|||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_stat(Thread *thread, ptr<char> path, ptr<Stat> ub) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, path, ub);
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, path, ub);
|
||||
auto result = sys_open(thread, path, 0, 0);
|
||||
if (result.isError()) {
|
||||
return result;
|
||||
return ErrorCode::NOENT;
|
||||
}
|
||||
|
||||
auto fd = thread->retval[0];
|
||||
|
|
@ -119,11 +119,18 @@ orbis::SysResult orbis::sys_stat(Thread *thread, ptr<char> path, ptr<Stat> ub) {
|
|||
}
|
||||
|
||||
auto len = thread->retval[0];
|
||||
*ub = {};
|
||||
ub->size = len;
|
||||
ub->blksize = 1;
|
||||
ub->blocks = len;
|
||||
ub->mode = 0777 | 0x8000;
|
||||
result = sys_pread(thread, fd, ub, 1, 0);
|
||||
if (result.isError()) {
|
||||
*ub = {};
|
||||
ub->mode = 0777 | 0x4000;
|
||||
} else {
|
||||
*ub = {};
|
||||
ub->size = len;
|
||||
ub->blksize = 1;
|
||||
ub->blocks = len;
|
||||
ub->mode = 0777 | 0x8000;
|
||||
}
|
||||
|
||||
sys_close(thread, fd);
|
||||
thread->retval[0] = 0;
|
||||
return {};
|
||||
|
|
|
|||
Loading…
Reference in a new issue