From 16a8503db450ef4ed8069d533f7e1a8dbe8cecaf Mon Sep 17 00:00:00 2001 From: Muhammed Ihsan <69343917+ihsan6133@users.noreply.github.com> Date: Tue, 24 Feb 2026 18:21:15 +0400 Subject: [PATCH] Added windows implementation for type_of_file. --- src/common.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/common.c b/src/common.c index 46bcfc50..0316da16 100644 --- a/src/common.c +++ b/src/common.c @@ -6,6 +6,7 @@ #ifdef _WIN32 # define MINIRENT_IMPLEMENTATION # include +# include #else # include # include @@ -133,7 +134,18 @@ Vec4f hex_to_vec4f(uint32_t color) Errno type_of_file(const char *file_path, File_Type *ft) { #ifdef _WIN32 -#error "TODO: type_of_file() is not implemented for Windows" + DWORD attr = GetFileAttributesA(file_path); + if (attr == INVALID_FILE_ATTRIBUTES) { + return GetLastError(); + } + + if (attr & FILE_ATTRIBUTE_DIRECTORY) { + *ft = FT_DIRECTORY; + } else if (attr & FILE_ATTRIBUTE_NORMAL || !(attr & FILE_ATTRIBUTE_DIRECTORY)) { + *ft = FT_REGULAR; + } else { + *ft = FT_OTHER; + } #else struct stat sb = {0}; if (stat(file_path, &sb) < 0) return errno;