Answers for "how to know if a file is a dir in c"

1

c check dir/file

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

int is_regular_file(const char *path)
{
    struct stat path_stat;
    stat(path, &path_stat);
    return S_ISREG(path_stat.st_mode);
}
Posted by: Guest on October-27-2020

Code answers related to "how to know if a file is a dir in c"

Browse Popular Code Answers by Language