SDL: io: Wrap IsRegularFileOrPipe in a more generic preprocessor test. (99399)

From 993993aaf3960b5a70a0e001cd2c827eb0888f6d Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Thu, 12 Mar 2026 11:26:45 -0400
Subject: [PATCH] io: Wrap IsRegularFileOrPipe in a more generic preprocessor
 test.

This way we can turn it off for various console platforms without changes
to this file.

(cherry picked from commit 4d675f2bd3c44a4f9ee28db30d8997ba19892aa8)
---
 src/io/SDL_iostream.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/io/SDL_iostream.c b/src/io/SDL_iostream.c
index 98a5cfe366146..4f1da7e812428 100644
--- a/src/io/SDL_iostream.c
+++ b/src/io/SDL_iostream.c
@@ -855,18 +855,22 @@ static bool SDLCALL mem_close(void *userdata)
 
 // Functions to create SDL_IOStream structures from various data sources
 
-#if defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINDOWS)
+// private platforms might define SKIP_STDIO_DIR_TEST in their build configs, too.
+#if defined(SDL_PLATFORM_WINDOWS) || defined(SDL_PLATFORM_EMSCRIPTEN)
+#define SKIP_STDIO_DIR_TEST 1
+#endif
+
+#if defined(HAVE_STDIO_H) && !defined(SKIP_STDIO_DIR_TEST)
 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;
 }
+#else
+#define IsRegularFileOrPipe(f) false
 #endif
 
 SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode)