summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/util.c b/util.c
index e0f6177..aef5fbb 100644
--- a/util.c
+++ b/util.c
@@ -17,6 +17,16 @@
#include <sys/types.h>
#include <unistd.h>
+int xreaddir(DIR *dir, struct dirent **de) {
+ errno = 0;
+ *de = readdir(dir);
+ if (!*de && errno != 0) {
+ return -1;
+ } else {
+ return 0;
+ }
+}
+
bool isopen(int fd) {
return fcntl(fd, F_GETFD) >= 0 || errno != EBADF;
}