implemented sceKernelClose

This commit is contained in:
georgemoralis 2023-11-06 22:57:06 +02:00
parent bd6d635a4b
commit 0f59f4a745
2 changed files with 16 additions and 4 deletions

View File

@ -1,5 +1,7 @@
#include "core/hle/libraries/libkernel/file_system.h" #include "core/hle/libraries/libkernel/file_system.h"
#include <filesystem> #include <filesystem>
#include "common/debug.h" #include "common/debug.h"
#include "common/log.h" #include "common/log.h"
#include "common/singleton.h" #include "common/singleton.h"
@ -29,7 +31,7 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) {
file->m_guest_name = path; file->m_guest_name = path;
file->m_host_name = mnt->getHostDirectory(file->m_guest_name); file->m_host_name = mnt->getHostDirectory(file->m_guest_name);
if (!std::filesystem::is_directory(file->m_host_name)) { // directory doesn't exist if (!std::filesystem::is_directory(file->m_host_name)) { // directory doesn't exist
if (create) { // if we have a create flag create it if (create) { // if we have a create flag create it
if (std::filesystem::create_directories(file->m_host_name)) { if (std::filesystem::create_directories(file->m_host_name)) {
return handle; return handle;
} else { } else {
@ -39,9 +41,9 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) {
} }
} else { } else {
if (create) { if (create) {
return handle;//directory already exists return handle; // directory already exists
} else { } else {
BREAKPOINT();//here we should handle open directory mode BREAKPOINT(); // here we should handle open directory mode
} }
} }
} }
@ -49,6 +51,15 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) {
return handle; return handle;
} }
int PS4_SYSV_ABI sceKernelClose(int handle) {
LOG_INFO_IF(log_file_fs, "sceKernelClose descriptor = {}\n", handle);
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
auto* file = h->getFile(handle);
file->isOpened = false;
h->deleteHandle(handle);
return SCE_OK;
}
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_IF(log_file_fs, "posix open redirect to sceKernelOpen\n"); LOG_INFO_IF(log_file_fs, "posix open redirect to sceKernelOpen\n");
int result = sceKernelOpen(path, flags, mode); int result = sceKernelOpen(path, flags, mode);
@ -60,6 +71,7 @@ int PS4_SYSV_ABI posix_open(const char* path, int flags, /* SceKernelMode*/ u16
void fileSystemSymbolsRegister(Loader::SymbolsResolver* sym) { void fileSystemSymbolsRegister(Loader::SymbolsResolver* sym) {
LIB_FUNCTION("1G3lF1Gg1k8", "libkernel", 1, "libkernel", 1, 1, sceKernelOpen); LIB_FUNCTION("1G3lF1Gg1k8", "libkernel", 1, "libkernel", 1, 1, sceKernelOpen);
LIB_FUNCTION("UK2Tl2DWUns", "libkernel", 1, "libkernel", 1, 1, sceKernelClose);
LIB_FUNCTION("wuCroIGjt2g", "libScePosix", 1, "libkernel", 1, 1, posix_open); LIB_FUNCTION("wuCroIGjt2g", "libScePosix", 1, "libkernel", 1, 1, posix_open);
} }

View File

@ -23,7 +23,7 @@ constexpr u32 SCE_KERNEL_O_DIRECT = 0x00010000; // Use cache as little as po
constexpr u32 SCE_KERNEL_O_DIRECTORY = 0x00020000; // Error will occur if not a directory constexpr u32 SCE_KERNEL_O_DIRECTORY = 0x00020000; // Error will occur if not a directory
int PS4_SYSV_ABI sceKernelOpen(const char *path, int flags, /* SceKernelMode*/ u16 mode); int PS4_SYSV_ABI sceKernelOpen(const char *path, int flags, /* SceKernelMode*/ u16 mode);
int PS4_SYSV_ABI sceKernelClose(int handle);
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);
void fileSystemSymbolsRegister(Loader::SymbolsResolver *sym); void fileSystemSymbolsRegister(Loader::SymbolsResolver *sym);