1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <sys/stat.h> #include <dirent.h> int c_is_dir(const char *path) { struct stat m; int r = stat(path, &m); return r == 0 && S_ISDIR(m.st_mode); } const char *get_d_name(struct dirent *d) { return (const char *) d->d_name; }