diff options
Diffstat (limited to 'nix/libutil/util.cc')
-rw-r--r-- | nix/libutil/util.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc index 9af42a150c..ad3b3c387f 100644 --- a/nix/libutil/util.cc +++ b/nix/libutil/util.cc @@ -223,6 +223,16 @@ DirEntries readDirectory(const Path & path) } +unsigned char getFileType(const Path & path) +{ + struct stat st = lstat(path); + if (S_ISDIR(st.st_mode)) return DT_DIR; + if (S_ISLNK(st.st_mode)) return DT_LNK; + if (S_ISREG(st.st_mode)) return DT_REG; + return DT_UNKNOWN; +} + + string readFile(int fd) { struct stat st; |