Skip to content

Commit 04defda

Browse files
authored
Merge pull request #8 from squidbus/create-error
Set error code when XCreateFileA fails on non-Windows
2 parents 383db89 + 0f5f06f commit 04defda

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

MarathonRecomp/kernel/io/file_system.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@ FileHandle* XCreateFileA
113113
{
114114
#ifdef _WIN32
115115
GuestThread::SetLastError(GetLastError());
116+
#else
117+
switch (errno)
118+
{
119+
case EACCES:
120+
GuestThread::SetLastError(ERROR_ACCESS_DENIED);
121+
break;
122+
case EEXIST:
123+
GuestThread::SetLastError(ERROR_FILE_EXISTS);
124+
break;
125+
case ENOENT:
126+
default: // Use ERROR_PATH_NOT_FOUND as a catch-all for other errors.
127+
GuestThread::SetLastError(ERROR_PATH_NOT_FOUND);
128+
break;
129+
}
116130
#endif
117131
return GetInvalidKernelObject<FileHandle>();
118132
}

MarathonRecomp/kernel/xdm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#define ERROR_NO_SUCH_USER 0x525
3939
#define ERROR_SUCCESS 0x0
4040
#define ERROR_PATH_NOT_FOUND 0x3
41+
#define ERROR_ACCESS_DENIED 0x5
42+
#define ERROR_FILE_EXISTS 0x50
4143
#define ERROR_BAD_ARGUMENTS 0xA0
4244
#define ERROR_DEVICE_NOT_CONNECTED 0x48F
4345
#define PAGE_READWRITE 0x04

0 commit comments

Comments
 (0)