-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw and error when DT_UNKNOWN is the d_type in Posix.ReadDir
- Loading branch information
Showing
5 changed files
with
111 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <sys/stat.h> | ||
|
||
int stat_is_directory(const char *path) { | ||
struct stat statbuf; | ||
|
||
// Call stat to get the file status | ||
if (stat(path, &statbuf) == 0) { | ||
// Check if the file is a directory using S_ISDIR macro | ||
if (S_ISDIR(statbuf.st_mode)) { | ||
return 1; // It is a directory | ||
} else { | ||
return 0; // Not a directory | ||
} | ||
} | ||
return -1; // An error occurred (stat failed) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters