use older stat tools for dos; newer stat tools for linux
This commit is contained in:
parent
b54f0119fc
commit
e4686ff786
13
src/cnadd.c
13
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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user