basic/stat-util: introduce is_dir_fd()
This commit is contained in:
parent
62f9666ae0
commit
a12e4ade1b
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue