diff options
author | Jim Meyering <jim@meyering.net> | 2004-04-18 13:09:27 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2004-04-18 13:09:27 +0000 |
commit | de48260615454b6815e02beaae09eafae26785aa (patch) | |
tree | 47c1464ad9fad4d93be37790a2a4093ab1a7dbad | |
parent | e71f800ae05ad7ba69e56ac94d555ce1ea2d22ba (diff) | |
download | coreutils-de48260615454b6815e02beaae09eafae26785aa.tar.xz |
(readdir_ignoring_dot_and_dotdot): New inline function, from remove.c.
-rw-r--r-- | src/system.h | 12 |
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) |