commit 4dedd87030b1b9deb5e3768bee5fe62d92bbbc25
Author: mrfox <jens.se@icloud.com>
AuthorDate: Tue Nov 24 22:25:30 2026 +0100
Commit: mrfox <jens.se@icloud.com>
CommitDate: Tue Nov 24 22:25:30 2026 +0100
xex fs test: close the stream before deleting; map sharing violation to EBUSY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---
platform/xex/runtime/fs.c | 5 +++++
platform/xex/tests/fs/main.cpp | 1 +
2 files changed, 6 insertions(+)
diff --git a/platform/xex/runtime/fs.c b/platform/xex/runtime/fs.c
index 439b48a..b21b1e0 100644
--- a/platform/xex/runtime/fs.c
+++ b/platform/xex/runtime/fs.c
@@ -33,6 +33,8 @@
#define STATUS_NOT_A_DIRECTORY 0xC0000103
#define STATUS_NO_SUCH_DEVICE 0xC000000E
#define STATUS_DISK_FULL 0xC000007F
+#define STATUS_SHARING_VIOLATION 0xC0000043
+#define STATUS_CANNOT_DELETE 0xC0000121
#ifndef FILE_LIST_DIRECTORY
#define FILE_LIST_DIRECTORY 0x00000001
@@ -74,6 +76,9 @@ static int status_to_errno(NTSTATUS status)
return ENOTDIR;
case STATUS_DISK_FULL:
return ENOSPC;
+ case STATUS_SHARING_VIOLATION:
+ case STATUS_CANNOT_DELETE:
+ return EBUSY;
default:
return EIO;
}
diff --git a/platform/xex/tests/fs/main.cpp b/platform/xex/tests/fs/main.cpp
index 2210a1e..e311949 100644
--- a/platform/xex/tests/fs/main.cpp
+++ b/platform/xex/tests/fs/main.cpp
@@ -71,6 +71,7 @@ static bool fileRoundTrip(const std::string &dir) {
std::string a, b;
std::getline(in, a);
std::getline(in, b);
+ in.close(); // an open file cannot be deleted on the console (sharing violation)
if (a != "hello xbox" || b != "line2") { errno = 0; return fail("readback '" + a + "'"); }
f = fopen(path.c_str(), "rb");