]> err.no Git - systemd/commitdiff
util: introduce dirent_is_file()
authorLennart Poettering <lennart@poettering.net>
Mon, 23 May 2011 19:39:15 +0000 (21:39 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 21 Jun 2011 17:29:43 +0000 (19:29 +0200)
src/util.c
src/util.h

index 4046938fcdbef876c9dfdee5f3bfc8d3faf52cfa..7f59021826d123ce75dbab6f6739c798f806ca2c 100644 (file)
@@ -4181,6 +4181,20 @@ finish:
         return r;
 }
 
+bool dirent_is_file(struct dirent *de) {
+        assert(de);
+
+        if (ignore_file(de->d_name))
+                return false;
+
+        if (de->d_type != DT_REG &&
+            de->d_type != DT_LNK &&
+            de->d_type != DT_UNKNOWN)
+                return false;
+
+        return true;
+}
+
 void execute_directory(const char *directory, DIR *d, char *argv[]) {
         DIR *_d = NULL;
         struct dirent *de;
@@ -4214,12 +4228,7 @@ void execute_directory(const char *directory, DIR *d, char *argv[]) {
                 pid_t pid;
                 int k;
 
-                if (ignore_file(de->d_name))
-                        continue;
-
-                if (de->d_type != DT_REG &&
-                    de->d_type != DT_LNK &&
-                    de->d_type != DT_UNKNOWN)
+                if (!dirent_is_file(de))
                         continue;
 
                 if (asprintf(&path, "%s/%s", directory, de->d_name) < 0) {
index 79d634bb6343b02dc0ea2dc0261740667daa4e96..f2156afb60cd31ac565bf049c211ec5bb9a2a7c3 100644 (file)
@@ -268,6 +268,7 @@ bool path_equal(const char *a, const char *b);
 
 char *ascii_strlower(char *path);
 
+bool dirent_is_file(struct dirent *de);
 bool ignore_file(const char *filename);
 
 bool chars_intersect(const char *a, const char *b);