summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/util.c b/util.c
index 2a01af1..01fb1ae 100644
--- a/util.c
+++ b/util.c
@@ -41,12 +41,20 @@
#endif
int xreaddir(DIR *dir, struct dirent **de) {
- errno = 0;
- *de = readdir(dir);
- if (!*de && errno != 0) {
- return -1;
- } else {
- return 0;
+ while (true) {
+ errno = 0;
+ *de = readdir(dir);
+
+ if (*de) {
+ const char *name = (*de)->d_name;
+ if (name[0] != '.' || (name[1] != '\0' && (name[1] != '.' || name[2] != '\0'))) {
+ return 0;
+ }
+ } else if (errno != 0) {
+ return -1;
+ } else {
+ return 0;
+ }
}
}