summaryrefslogtreecommitdiff
path: root/src/system.h
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-04-18 13:09:27 +0000
committerJim Meyering <jim@meyering.net>2004-04-18 13:09:27 +0000
commitde48260615454b6815e02beaae09eafae26785aa (patch)
tree47c1464ad9fad4d93be37790a2a4093ab1a7dbad /src/system.h
parente71f800ae05ad7ba69e56ac94d555ce1ea2d22ba (diff)
downloadcoreutils-de48260615454b6815e02beaae09eafae26785aa.tar.xz
(readdir_ignoring_dot_and_dotdot): New inline function, from remove.c.
Diffstat (limited to 'src/system.h')
-rw-r--r--src/system.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/system.h b/src/system.h
index 978b613d9..17b6da1dd 100644
--- a/src/system.h
+++ b/src/system.h
@@ -572,6 +572,18 @@ uid_t getuid ();
(Basename[0] == '.' && (Basename[1] == '\0' \
|| (Basename[1] == '.' && Basename[2] == '\0')))
+/* A wrapper for readdir so that callers don't see entries for `.' or `..'. */
+static inline struct dirent const *
+readdir_ignoring_dot_and_dotdot (DIR *dirp)
+{
+ while (1)
+ {
+ struct dirent const *dp = readdir (dirp);
+ if (dp == NULL || ! DOT_OR_DOTDOT (dp->d_name))
+ return dp;
+ }
+}
+
#if SETVBUF_REVERSED
# define SETVBUF(Stream, Buffer, Type, Size) \
setvbuf (Stream, Type, Buffer, Size)