From e4686ff7864f0a2719092a19e9f19b2908968097 Mon Sep 17 00:00:00 2001 From: Gregory Gauthier Date: Wed, 4 Feb 2026 16:29:56 +0000 Subject: [PATCH] use older stat tools for dos; newer stat tools for linux --- src/cnadd.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/cnadd.c b/src/cnadd.c index 4413542..c1dca06 100644 --- a/src/cnadd.c +++ b/src/cnadd.c @@ -11,10 +11,19 @@ int ensure_directory_exists(const char *path) { struct stat st; if (stat(path, &st) == 0) { - /* Path exists, check if it's a directory using bit test */ + /* Path exists, check if it's a directory */ +#if defined(__MSDOS__) || defined(__DOS__) + /* DOS/Turbo C: use bit test because S_ISDIR macro may be missing */ if ((st.st_mode & S_IFMT) == S_IFDIR) { return 1; - } else { + } +#else + /* Unix/Linux/Windows modern: use standard POSIX macro */ + if (S_ISDIR(st.st_mode)) { + return 1; + } +#endif + else { fprintf(stderr, "Error: %s exists but is not a directory\n", path); return 0; }