summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-10-23 21:36:38 +0200
committerLennart Poettering <lennart@poettering.net>2014-10-23 21:36:56 +0200
commitbe57e297acd0ae41044c99a7c41f95a8339a314c (patch)
tree9bc4a37bdc0746c3dc9e6979495bcaebe005dc53 /src/shared/util.c
parentc34255bdb217c2a1d3ac6348252437ab8be9ca46 (diff)
label: move is_dir() to util.c
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) {