chiark / gitweb /
sd-login: read list of uids of sessions from UIDS not ACTIVE_SESSIONS
[elogind.git] / src / basic / dirent-util.c
index 5019882a0adda998a8b41de6735089c4a81b85ea..5bf58bcdc36d442022e1ef6a82965e06aecfcdf2 100644 (file)
@@ -52,10 +52,10 @@ int dirent_ensure_type(DIR *d, struct dirent *de) {
 bool dirent_is_file(const struct dirent *de) {
         assert(de);
 
-        if (hidden_file(de->d_name))
+        if (!IN_SET(de->d_type, DT_REG, DT_LNK, DT_UNKNOWN))
                 return false;
 
-        if (!IN_SET(de->d_type, DT_REG, DT_LNK, DT_UNKNOWN))
+        if (hidden_or_backup_file(de->d_name))
                 return false;
 
         return true;
@@ -70,5 +70,19 @@ bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) {
         if (de->d_name[0] == '.')
                 return false;
 
+        if (!suffix)
+                return true;
+
         return endswith(de->d_name, suffix);
 }
+
+struct dirent* readdir_no_dot(DIR *dirp) {
+        struct dirent* d;
+
+        for (;;) {
+                d = readdir(dirp);
+                if (d && dot_or_dot_dot(d->d_name))
+                        continue;
+                return d;
+        }
+}