mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:07:45 +00:00
LibC: Implement the rewinddir() function
This commit is contained in:
parent
8d6e9fad40
commit
2447dcd1ea
2 changed files with 11 additions and 2 deletions
|
@ -35,7 +35,6 @@ int closedir(DIR* dirp)
|
||||||
{
|
{
|
||||||
if (!dirp || dirp->fd == -1)
|
if (!dirp || dirp->fd == -1)
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
if (dirp->buffer)
|
|
||||||
free(dirp->buffer);
|
free(dirp->buffer);
|
||||||
int rc = close(dirp->fd);
|
int rc = close(dirp->fd);
|
||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
|
@ -44,6 +43,15 @@ int closedir(DIR* dirp)
|
||||||
return rc;
|
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 {
|
struct [[gnu::packed]] sys_dirent {
|
||||||
ino_t ino;
|
ino_t ino;
|
||||||
u8 file_type;
|
u8 file_type;
|
||||||
|
|
|
@ -50,6 +50,7 @@ typedef struct __DIR DIR;
|
||||||
|
|
||||||
DIR* opendir(const char* name);
|
DIR* opendir(const char* name);
|
||||||
int closedir(DIR*);
|
int closedir(DIR*);
|
||||||
|
void rewinddir(DIR*);
|
||||||
struct dirent* readdir(DIR*);
|
struct dirent* readdir(DIR*);
|
||||||
int readdir_r(DIR*, struct dirent*, struct dirent**);
|
int readdir_r(DIR*, struct dirent*, struct dirent**);
|
||||||
int dirfd(DIR*);
|
int dirfd(DIR*);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue