From 1c7cc602863821ee62dac65d9e3c26fcc2710b3c Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 27 Jan 2025 22:25:12 -0800
Subject: [PATCH] Skip IsRegularFileOrPipe() check on Emscripten
The sandbox guarantees that this will be true.
Fixes https://github.com/libsdl-org/SDL/issues/12108
---
src/io/SDL_iostream.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/io/SDL_iostream.c b/src/io/SDL_iostream.c
index 7f97dfeb3cdc1..989f3b9c4c0fd 100644
--- a/src/io/SDL_iostream.c
+++ b/src/io/SDL_iostream.c
@@ -788,10 +788,13 @@ static bool SDLCALL mem_close(void *userdata)
#if defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINDOWS)
static bool IsRegularFileOrPipe(FILE *f)
{
+#ifndef SDL_PLATFORM_EMSCRIPTEN
struct stat st;
if (fstat(fileno(f), &st) < 0 || !(S_ISREG(st.st_mode) || S_ISFIFO(st.st_mode))) {
return false;
}
+#endif // !SDL_PLATFORM_EMSCRIPTEN
+
return true;
}
#endif