summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 5f6249eb04..bc97c67f76 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -6933,10 +6933,21 @@ int is_symlink(const char *path) {
if (lstat(path, &info) < 0)
return -errno;
- if (S_ISLNK(info.st_mode))
- return 1;
+ return !!S_ISLNK(info.st_mode);
+}
- return 0;
+int is_dir(const char* path, bool follow) {
+ struct stat st;
+
+ if (follow) {
+ if (stat(path, &st) < 0)
+ return -errno;
+ } else {
+ if (lstat(path, &st) < 0)
+ return -errno;
+ }
+
+ return !!S_ISDIR(st.st_mode);
}
int unquote_first_word(const char **p, char **ret) {