From 07cfc34a2ead14a461ce36a5d7fb570b1291d359 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 6 Aug 2024 05:45:48 -0700
Subject: [PATCH] Added detail about why a file couldn't be opened (thanks
mgerhardy!)
Fixes https://github.com/libsdl-org/SDL/issues/10484
(cherry picked from commit 15120133202da5980c17b4bf363b5fdb6f32de6b)
---
src/file/SDL_rwops.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c
index bf47ba7110b4d..444bf4af3d5c5 100644
--- a/src/file/SDL_rwops.c
+++ b/src/file/SDL_rwops.c
@@ -36,6 +36,7 @@
#ifdef HAVE_STDIO_H
#include <stdio.h>
+#include <errno.h>
#include <sys/stat.h>
#endif
#ifdef HAVE_LIMITS_H
@@ -632,7 +633,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
FILE *fp = fopen(file, mode);
#endif
if (!fp) {
- SDL_SetError("Couldn't open %s", file);
+ SDL_SetError("Couldn't open %s: %s", file, strerror(errno));
} else if (!IsRegularFileOrPipe(fp)) {
fclose(fp);
fp = NULL;