diff --git a/src/core/hle/libraries/libkernel/file_system.cpp b/src/core/hle/libraries/libkernel/file_system.cpp index 4511e865..61bd077d 100644 --- a/src/core/hle/libraries/libkernel/file_system.cpp +++ b/src/core/hle/libraries/libkernel/file_system.cpp @@ -1,5 +1,7 @@ #include "core/hle/libraries/libkernel/file_system.h" + #include + #include "common/debug.h" #include "common/log.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_host_name = mnt->getHostDirectory(file->m_guest_name); 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)) { return handle; } else { @@ -39,9 +41,9 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) { } } else { if (create) { - return handle;//directory already exists + return handle; // directory already exists } 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; } +int PS4_SYSV_ABI sceKernelClose(int handle) { + LOG_INFO_IF(log_file_fs, "sceKernelClose descriptor = {}\n", handle); + auto* h = Common::Singleton::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) { LOG_INFO_IF(log_file_fs, "posix open redirect to sceKernelOpen\n"); 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) { 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); } diff --git a/src/core/hle/libraries/libkernel/file_system.h b/src/core/hle/libraries/libkernel/file_system.h index 7e58c541..277be463 100644 --- a/src/core/hle/libraries/libkernel/file_system.h +++ b/src/core/hle/libraries/libkernel/file_system.h @@ -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 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); void fileSystemSymbolsRegister(Loader::SymbolsResolver *sym);