basic/stat-util: introduce is_dir_fd()

This commit is contained in:
Franck Bui 2018-07-20 09:05:38 +02:00
parent 62f9666ae0
commit a12e4ade1b
2 changed files with 12 additions and 0 deletions

View File

@ -45,6 +45,17 @@ int is_dir(const char* path, bool follow) {
return !!S_ISDIR(st.st_mode);
}
int is_dir_fd(int fd) {
struct stat st;
int r;
r = fstat(fd, &st);
if (r < 0)
return -errno;
return !!S_ISDIR(st.st_mode);
}
int is_device_node(const char *path) {
struct stat info;

View File

@ -12,6 +12,7 @@
int is_symlink(const char *path);
int is_dir(const char *path, bool follow);
int is_dir_fd(int fd);
int is_device_node(const char *path);
int dir_is_empty(const char *path);