REWINDDIR(3POSIX)
π« REWINDDIR(3POSIX) π«
okay bestie, welcome to the POSIX Programmer's Manual β¨ this one's about rewinddir, and it's genuinely one of the chillest little functions in <dirent.h>. no cap.
πΈ PROLOG πΈ
real talk before we even start: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
so likeβ¦ check your local page too, bestie. different platforms, different vibes. π«Ά
π NAME π
rewinddir β reset the position of a directory stream to the beginning of a directory
it does exactly what it says on the tin, and honestly? iconic behaviour. π
β¨ SYNOPSIS β¨
#include <dirent.h>
void rewinddir(DIR *dirp);
that's it. that's the whole thing. one include, one call, no return value, no drama. π
π¦ DESCRIPTION π¦
So here's the tea. β
The rewinddir() function shall reset the position of the directory stream to which dirp refers to the beginning of the directory. Like, you scrolled all the way to the bottom of the feed and now you're back at the top. β¬οΈ
It shall also cause the directory stream to refer to the current state of the corresponding directory, as a call to opendir() would have done. So it's not just a rewind β it's a refresh, bestie. it's giving "close and reopen but without the extra steps". π₯
β οΈ careful though: if dirp does not refer to a directory stream, the effect is undefined. not "probably fine", not "it'll throw an error" β undefined. do not test it. π
And now the fork lore, because this part is lowkey important: after a call to the fork() function, either the parent or child (but not both) may continue processing the directory stream using readdir(), rewinddir(), or seekdir(). If both the parent and child processes use these functions, the result is undefined.
π so pick a lane. one of you gets the directory stream. the other oneβ¦ doesn't. that's the rule.
π RETURN VALUE π
The rewinddir() function shall not return a value.
literally returns nothing. void. silent. mysterious. main character energy. π€«
π ERRORS π
No errors are defined.
zero. none. nada. she simply does not fail on you (per spec, anyway π ).
The following sections are informative.
π EXAMPLES π
None.
sorry bestie, the standards committee left this one blank. we move. π
π§ APPLICATION USAGE π§
The rewinddir() function should be used in conjunction with opendir(), readdir(), and closedir() to examine the contents of the directory. This method is recommended for portability.
π«Ά so like, use the whole squad together βopendir(),readdir(),closedir()β and you're portable. iykyk.
π RATIONALE π
None.
no reasoning given. she just is. β
πΈ FUTURE DIRECTIONS πΈ
None.
the future is bright and also empty for this one. π
π₯ SEE ALSO π₯
closedir()fdopendir()readdir()
The Base Definitions volume of POSIX.1β2017, <dirent.h>, <sys_types.h>
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie!! π this came to you from the IEEE/The Open Group, dated 2017, and yeah β it's REWINDDIR(3POSIX). slay, go rewind something. πβ¨π¦
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms