Tests whether a given path is a directory (or a symlink to a directory)
Download (right click, save as, rename as appropriate)
1 2 3 4 5 6 7
#include <sys/stat.h> /* Returns 1 if the path is a directory or directory symlink, 0 if it's not, -1 on error */ int isadir(const char* path) { struct stat dat; return stat(path, &dat) == 0 ? S_ISDIR(dat.st_mode) : -1; }