mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibC: Implement the rewinddir() function
This commit is contained in:
parent
8d6e9fad40
commit
2447dcd1ea
Notes:
sideshowbarker
2024-07-18 19:07:37 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/2447dcd1eab Pull-request: https://github.com/SerenityOS/serenity/pull/6630 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/emanuele6
2 changed files with 11 additions and 2 deletions
|
@ -35,8 +35,7 @@ int closedir(DIR* dirp)
|
|||
{
|
||||
if (!dirp || dirp->fd == -1)
|
||||
return -EBADF;
|
||||
if (dirp->buffer)
|
||||
free(dirp->buffer);
|
||||
free(dirp->buffer);
|
||||
int rc = close(dirp->fd);
|
||||
if (rc == 0)
|
||||
dirp->fd = -1;
|
||||
|
@ -44,6 +43,15 @@ int closedir(DIR* dirp)
|
|||
return rc;
|
||||
}
|
||||
|
||||
void rewinddir(DIR* dirp)
|
||||
{
|
||||
free(dirp->buffer);
|
||||
dirp->buffer = nullptr;
|
||||
dirp->buffer_size = 0;
|
||||
dirp->nextptr = nullptr;
|
||||
lseek(dirp->fd, 0, SEEK_SET);
|
||||
}
|
||||
|
||||
struct [[gnu::packed]] sys_dirent {
|
||||
ino_t ino;
|
||||
u8 file_type;
|
||||
|
|
|
@ -50,6 +50,7 @@ typedef struct __DIR DIR;
|
|||
|
||||
DIR* opendir(const char* name);
|
||||
int closedir(DIR*);
|
||||
void rewinddir(DIR*);
|
||||
struct dirent* readdir(DIR*);
|
||||
int readdir_r(DIR*, struct dirent*, struct dirent**);
|
||||
int dirfd(DIR*);
|
||||
|
|
Loading…
Reference in a new issue