commit:     19df31a23a3a5ab08abde6cea7f4b8bfd44fd07c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 26 13:48:12 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Dec 26 13:48:12 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=19df31a2

libq/scandirat: add filter_self_parent func

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 libq/scandirat.c | 18 +++++++++++++++---
 libq/scandirat.h |  9 +++++++--
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/libq/scandirat.c b/libq/scandirat.c
index f28ba0d..ec4b691 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        - <[email protected]>
@@ -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 950cbb1..1ac2b50 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        - <[email protected]>
+ * Copyright 2005-2014 Mike Frysinger  - <[email protected]>
+ * Copyright 2021-     Fabian Groffen  - <[email protected]>
  */
 
 #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

Reply via email to