Welcome to little lamb

Code » limb » commit 5ab10cf

direntry.h: Add macro ISDOTDOT()

author Olivier Brunel
2023-05-09 18:29:55 UTC
committer Olivier Brunel
2023-07-05 07:37:02 UTC
parent ee917f360b605787fed659ab80481f3a744d24b1

direntry.h: Add macro ISDOTDOT()

src/doc/direntry.h.0.md +7 -0
src/liblimb/include/limb/direntry.h +2 -0

diff --git a/src/doc/direntry.h.0.md b/src/doc/direntry.h.0.md
index becdd7b..6935be2 100644
--- a/src/doc/direntry.h.0.md
+++ b/src/doc/direntry.h.0.md
@@ -19,6 +19,13 @@ The header defines the needed functions to deal with directory streams.
 ! This header is a complement to skalibs' own [skalibs/direntry.h](0) and thusly
 ! includes said header.
 
+## Macros
+
+The following macros are defined :
+
+: *ISDOTDOT(`de`)*
+:: Returns whether the pointed *direntry* is that of the `.` or `..` file
+
 ## Functions
 
 The following functions are defined :
diff --git a/src/liblimb/include/limb/direntry.h b/src/liblimb/include/limb/direntry.h
index c7356e7..cfcfdbc 100644
--- a/src/liblimb/include/limb/direntry.h
+++ b/src/liblimb/include/limb/direntry.h
@@ -6,6 +6,8 @@
 
 #include <skalibs/direntry.h>
 
+#define ISDOTDOT(de)    ((de)->d_name[0] == '.' && (!(de)->d_name[1] || ((de)->d_name[1] == '.' && !(de)->d_name[2])))
+
 extern DIR *opendirat(int bfd, const char *name);
 
 #endif /* LIMB_DIRENTRY_H */