From 0f5f06fcf66cb4adbff9d142608a91cf8f8c810c Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Sat, 19 Jul 2025 03:08:41 -0700 Subject: [PATCH] Set error code when XCreateFileA fails on non-Windows --- MarathonRecomp/kernel/io/file_system.cpp | 14 ++++++++++++++ MarathonRecomp/kernel/xdm.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/MarathonRecomp/kernel/io/file_system.cpp b/MarathonRecomp/kernel/io/file_system.cpp index 478e973ac..a5be0e71a 100644 --- a/MarathonRecomp/kernel/io/file_system.cpp +++ b/MarathonRecomp/kernel/io/file_system.cpp @@ -113,6 +113,20 @@ FileHandle* XCreateFileA { #ifdef _WIN32 GuestThread::SetLastError(GetLastError()); +#else + switch (errno) + { + case EACCES: + GuestThread::SetLastError(ERROR_ACCESS_DENIED); + break; + case EEXIST: + GuestThread::SetLastError(ERROR_FILE_EXISTS); + break; + case ENOENT: + default: // Use ERROR_PATH_NOT_FOUND as a catch-all for other errors. + GuestThread::SetLastError(ERROR_PATH_NOT_FOUND); + break; + } #endif return GetInvalidKernelObject(); } diff --git a/MarathonRecomp/kernel/xdm.h b/MarathonRecomp/kernel/xdm.h index e1619cee5..b001970bf 100644 --- a/MarathonRecomp/kernel/xdm.h +++ b/MarathonRecomp/kernel/xdm.h @@ -38,6 +38,8 @@ #define ERROR_NO_SUCH_USER 0x525 #define ERROR_SUCCESS 0x0 #define ERROR_PATH_NOT_FOUND 0x3 +#define ERROR_ACCESS_DENIED 0x5 +#define ERROR_FILE_EXISTS 0x50 #define ERROR_BAD_ARGUMENTS 0xA0 #define ERROR_DEVICE_NOT_CONNECTED 0x48F #define PAGE_READWRITE 0x04