Permalink
Browse files

basic/stat-util: introduce is_dir_fd()

  • Loading branch information...
fbuihuu committed Jul 20, 2018
1 parent 62f9666 commit a12e4ade1b7634f7286f53d9ce2b3a12ab17826e
Showing with 12 additions and 0 deletions.
  1. +11 −0 src/basic/stat-util.c
  2. +1 −0 src/basic/stat-util.h
@@ -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;

@@ -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);

0 comments on commit a12e4ad

Please sign in to comment.