aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2021-12-26 14:48:12 +0100
committerFabian Groffen <grobian@gentoo.org>2021-12-26 14:48:12 +0100
commit19df31a23a3a5ab08abde6cea7f4b8bfd44fd07c (patch)
tree1ae0e468a9bfec5ed9e3a3cef2f3ead60e8b1f91
parentqlop: fix garbage when using -Ev (diff)
downloadportage-utils-19df31a23a3a5ab08abde6cea7f4b8bfd44fd07c.tar.gz
portage-utils-19df31a23a3a5ab08abde6cea7f4b8bfd44fd07c.tar.bz2
portage-utils-19df31a23a3a5ab08abde6cea7f4b8bfd44fd07c.zip
libq/scandirat: add filter_self_parent func
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
-rw-r--r--libq/scandirat.c18
-rw-r--r--libq/scandirat.h9
2 files changed, 22 insertions, 5 deletions
diff --git a/libq/scandirat.c b/libq/scandirat.c
index f28ba0d8..ec4b691b 100644
--- a/libq/scandirat.c
+++ b/libq/scandirat.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2019 Gentoo Foundation
+ * Copyright 2005-2021 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
*
* Copyright 2005-2010 Ned Ludd - <solar@gentoo.org>
@@ -87,9 +87,21 @@ scandir_free(struct dirent **de, int cnt)
}
int
-filter_hidden(const struct dirent *dentry)
+filter_hidden(const struct dirent *de)
{
- if (dentry->d_name[0] == '.')
+ if (de->d_name[0] == '.')
return 0;
return 1;
}
+
+int
+filter_self_parent(const struct dirent *de)
+{
+ if (de->d_name[0] == '.' &&
+ (de->d_name[1] == '\0' ||
+ (de->d_name[1] == '.' &&
+ de->d_name[2] == '\0')))
+ return 0;
+
+ return 1;
+}
diff --git a/libq/scandirat.h b/libq/scandirat.h
index 950cbb1a..1ac2b50c 100644
--- a/libq/scandirat.h
+++ b/libq/scandirat.h
@@ -1,6 +1,10 @@
/*
- * Copyright 2005-2019 Gentoo Foundation
+ * Copyright 2005-2021 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
+ *
+ * Copyright 2005-2010 Ned Ludd - <solar@gentoo.org>
+ * Copyright 2005-2014 Mike Frysinger - <vapier@gentoo.org>
+ * Copyright 2021- Fabian Groffen - <grobian@gentoo.org>
*/
#ifndef _SCANDIRAT_H
@@ -19,6 +23,7 @@ int scandirat(
#endif
void scandir_free(struct dirent **de, int cnt);
-int filter_hidden(const struct dirent *dentry);
+int filter_hidden(const struct dirent *de);
+int filter_self_parent(const struct dirent *de);
#endif