WIP : sceKernelOpen directory opening

This commit is contained in:
georgemoralis 2024-06-01 16:30:15 +03:00
parent fc38cf0d8b
commit b6ffedba85
1 changed files with 17 additions and 7 deletions

View File

@ -30,12 +30,23 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) {
bool dsync = (flags & ORBIS_KERNEL_O_DSYNC) != 0; bool dsync = (flags & ORBIS_KERNEL_O_DSYNC) != 0;
bool direct = (flags & ORBIS_KERNEL_O_DIRECT) != 0; bool direct = (flags & ORBIS_KERNEL_O_DIRECT) != 0;
bool directory = (flags & ORBIS_KERNEL_O_DIRECTORY) != 0; bool directory = (flags & ORBIS_KERNEL_O_DIRECTORY) != 0;
if (directory) {
UNREACHABLE(); // not supported yet
} else {
u32 handle = h->CreateHandle(); u32 handle = h->CreateHandle();
auto* file = h->GetFile(handle); auto* file = h->GetFile(handle);
if (directory) {
file->is_directory = true;
file->m_guest_name = path;
file->m_host_name = mnt->GetHostDirectory(file->m_guest_name);
if (!std::filesystem::is_directory(file->m_host_name)) { // directory doesn't exist
UNREACHABLE(); // not supported yet
} else {
if (create) {
return handle; // dir already exists
} else {
// get dirents TODO
file->dirents_index = 0;
}
}
} else {
file->m_guest_name = path; file->m_guest_name = path;
file->m_host_name = mnt->GetHostFile(file->m_guest_name); file->m_host_name = mnt->GetHostFile(file->m_guest_name);
if (read) { if (read) {
@ -49,11 +60,10 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) {
h->DeleteHandle(handle); h->DeleteHandle(handle);
return SCE_KERNEL_ERROR_EACCES; return SCE_KERNEL_ERROR_EACCES;
} }
}
file->is_opened = true; file->is_opened = true;
return handle; return handle;
} }
return -1; // dummy
}
int PS4_SYSV_ABI posix_open(const char* path, int flags, /* SceKernelMode*/ u16 mode) { int PS4_SYSV_ABI posix_open(const char* path, int flags, /* SceKernelMode*/ u16 mode) {
LOG_INFO(Kernel_Fs, "posix open redirect to sceKernelOpen\n"); LOG_INFO(Kernel_Fs, "posix open redirect to sceKernelOpen\n");