From 2c51c9f5f8a88126e4649c530d31bf2cd1caa254 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 26 Aug 2025 08:36:00 +0100 Subject: [PATCH] use GetFileAttributes for pathisdirectory on Windows should slightly speedup gamestartup with autoloaded files --- src/filesrch.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/filesrch.c b/src/filesrch.c index 9592c63c2..74ff1ef53 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -341,6 +341,7 @@ char *refreshdirname = NULL; // direrror is set if there was an error. INT32 pathisdirectory(const char *path) { +#ifndef _WIN32 struct stat fsstat; if (stat(path, &fsstat) < 0) @@ -348,7 +349,21 @@ INT32 pathisdirectory(const char *path) return -1; } else if (S_ISDIR(fsstat.st_mode)) + { return 1; + } + +#else + DWORD fileattr = GetFileAttributes(path); + if (fileattr == INVALID_FILE_ATTRIBUTES) + { + return -1; + } + else if (fileattr & FILE_ATTRIBUTE_DIRECTORY) + { + return 1; + } +#endif return 0; }