I want to know if a file is a directory or a regular file with stat :

```
#define _DEFAULT_SOURCE

#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);
}

```

I try on Mac and Linux and when I print S\_ISREG(path\_stat.st\_mode) is always equal to 1 and path\_stat.st\_mode is always equal to 16877.