summaryrefslogtreecommitdiff
path: root/libc/misc/dirent/rewinddir.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc/dirent/rewinddir.c')
-rw-r--r--libc/misc/dirent/rewinddir.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libc/misc/dirent/rewinddir.c b/libc/misc/dirent/rewinddir.c
new file mode 100644
index 000000000..9d147fca2
--- /dev/null
+++ b/libc/misc/dirent/rewinddir.c
@@ -0,0 +1,15 @@
+#include <errno.h>
+#include <unistd.h>
+#include "dirstream.h"
+
+
+/* rewinddir() just does an lseek(fd,0,0) - see close for comments */
+void rewinddir(DIR * dir)
+{
+ if (!dir) {
+ errno = EBADF;
+ return;
+ }
+ lseek(dir->dd_fd, 0, SEEK_SET);
+ dir->dd_nextoff = dir->dd_nextloc = dir->dd_size = 0;
+}