From 92f3cb39168bdcb8e5402b5c4887c75a7c2f1100 Mon Sep 17 00:00:00 2001 From: Pouare514 Date: Fri, 2 Oct 2026 20:19:05 +0200 Subject: [PATCH] fix(libc): return NULL with ENOENT for missing files in fopen --- core/libs/prx/libc/src/FileAndHeap.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/libs/prx/libc/src/FileAndHeap.cpp b/core/libs/prx/libc/src/FileAndHeap.cpp index 04294ca2d..a0d830246 100644 --- a/core/libs/prx/libc/src/FileAndHeap.cpp +++ b/core/libs/prx/libc/src/FileAndHeap.cpp @@ -41,7 +41,12 @@ FileStream* APS5_VABI fopen_nid_postfix(const char* filename, const char* mode) const auto abs_path = fpath.string(); std::unique_ptr handle(std::fopen(abs_path.c_str(), mode), std::fclose); if (!handle) { - const auto reason = std::strerror(errno); + const int error = errno; + if (error == ENOENT) { + errno = error; + return nullptr; + } + const auto reason = std::strerror(error); std::error_code ec; std::filesystem::path sibling; for (const auto& entry : std::filesystem::directory_iterator(fpath.parent_path(), ec)) {