use older stat tools for dos; newer stat tools for linux
All checks were successful
Build / build (push) Successful in 14s
Release / release (push) Successful in 27s

This commit is contained in:
Gregory Gauthier 2026-02-04 16:29:56 +00:00
parent b54f0119fc
commit e4686ff786

View File

@ -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;
}