From 8be92f2074d8bdb884ab7fcef32f4b460cb9516a Mon Sep 17 00:00:00 2001 From: ElBread3 <92335081+ElBread3@users.noreply.github.com> Date: Sat, 28 Sep 2024 18:37:43 -0500 Subject: [PATCH] fix return value problem --- src/core/libraries/kernel/file_system.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/core/libraries/kernel/file_system.cpp b/src/core/libraries/kernel/file_system.cpp index 123a389b4..c106e94d0 100644 --- a/src/core/libraries/kernel/file_system.cpp +++ b/src/core/libraries/kernel/file_system.cpp @@ -317,32 +317,39 @@ int PS4_SYSV_ABI sceKernelRmdir(const char* path) { const std::filesystem::path dir_name = mnt->GetHostPath(path, &ro); if (dir_name.empty()) { - LOG_INFO(Kernel_Fs, "Failed to remove directory: {}, permission denied", path); + LOG_INFO(Kernel_Fs, "Failed to remove directory: {}, permission denied", + fmt::UTF(dir_name.u8string())); return SCE_KERNEL_ERROR_EACCES; } if (ro) { - LOG_INFO(Kernel_Fs, "Failed to remove directory: {}, directory is read only", path); + LOG_INFO(Kernel_Fs, "Failed to remove directory: {}, directory is read only", + fmt::UTF(dir_name.u8string())); return SCE_KERNEL_ERROR_EROFS; } if (!std::filesystem::is_directory(dir_name)) { - LOG_INFO(Kernel_Fs, "Failed to remove directory: {}, path is not a directory", path); + LOG_INFO(Kernel_Fs, "Failed to remove directory: {}, path is not a directory", + fmt::UTF(dir_name.u8string())); return ORBIS_KERNEL_ERROR_ENOTDIR; } if (!std::filesystem::exists(dir_name)) { - LOG_INFO(Kernel_Fs, "Failed to remove directory: {}, no such file or directory", path); + LOG_INFO(Kernel_Fs, "Failed to remove directory: {}, no such file or directory", + fmt::UTF(dir_name.u8string())); return ORBIS_KERNEL_ERROR_ENOENT; } - int result = std::filesystem::remove_all(dir_name); + std::error_code ec; + int result = std::filesystem::remove_all(dir_name, ec); - if (result > 0) { - LOG_DEBUG(Kernel_Fs, "Removed directory: {}", path); + if (!ec) { + LOG_DEBUG(Kernel_Fs, "Removed directory: {}", fmt::UTF(dir_name.u8string())); return ORBIS_OK; } - return result; + LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, error_code={}", + fmt::UTF(dir_name.u8string()), ec.message()); + return ErrnoToSceKernelError(ec.value()); } int PS4_SYSV_ABI posix_rmdir(const char* path) {