Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: libq/
Date: Sun, 26 Dec 2021 14:00:00
Message-Id: 1640526492.19df31a23a3a5ab08abde6cea7f4b8bfd44fd07c.grobian@gentoo
1 commit: 19df31a23a3a5ab08abde6cea7f4b8bfd44fd07c
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Sun Dec 26 13:48:12 2021 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Sun Dec 26 13:48:12 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=19df31a2
7
8 libq/scandirat: add filter_self_parent func
9
10 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
11
12 libq/scandirat.c | 18 +++++++++++++++---
13 libq/scandirat.h | 9 +++++++--
14 2 files changed, 22 insertions(+), 5 deletions(-)
15
16 diff --git a/libq/scandirat.c b/libq/scandirat.c
17 index f28ba0d..ec4b691 100644
18 --- a/libq/scandirat.c
19 +++ b/libq/scandirat.c
20 @@ -1,5 +1,5 @@
21 /*
22 - * Copyright 2005-2019 Gentoo Foundation
23 + * Copyright 2005-2021 Gentoo Foundation
24 * Distributed under the terms of the GNU General Public License v2
25 *
26 * Copyright 2005-2010 Ned Ludd - <solar@g.o>
27 @@ -87,9 +87,21 @@ scandir_free(struct dirent **de, int cnt)
28 }
29
30 int
31 -filter_hidden(const struct dirent *dentry)
32 +filter_hidden(const struct dirent *de)
33 {
34 - if (dentry->d_name[0] == '.')
35 + if (de->d_name[0] == '.')
36 return 0;
37 return 1;
38 }
39 +
40 +int
41 +filter_self_parent(const struct dirent *de)
42 +{
43 + if (de->d_name[0] == '.' &&
44 + (de->d_name[1] == '\0' ||
45 + (de->d_name[1] == '.' &&
46 + de->d_name[2] == '\0')))
47 + return 0;
48 +
49 + return 1;
50 +}
51
52 diff --git a/libq/scandirat.h b/libq/scandirat.h
53 index 950cbb1..1ac2b50 100644
54 --- a/libq/scandirat.h
55 +++ b/libq/scandirat.h
56 @@ -1,6 +1,10 @@
57 /*
58 - * Copyright 2005-2019 Gentoo Foundation
59 + * Copyright 2005-2021 Gentoo Foundation
60 * Distributed under the terms of the GNU General Public License v2
61 + *
62 + * Copyright 2005-2010 Ned Ludd - <solar@g.o>
63 + * Copyright 2005-2014 Mike Frysinger - <vapier@g.o>
64 + * Copyright 2021- Fabian Groffen - <grobian@g.o>
65 */
66
67 #ifndef _SCANDIRAT_H
68 @@ -19,6 +23,7 @@ int scandirat(
69 #endif
70
71 void scandir_free(struct dirent **de, int cnt);
72 -int filter_hidden(const struct dirent *dentry);
73 +int filter_hidden(const struct dirent *de);
74 +int filter_self_parent(const struct dirent *de);
75
76 #endif