diff options
| author | Anton Kling <anton@kling.gg> | 2024-10-03 14:20:51 +0200 | 
|---|---|---|
| committer | Anton Kling <anton@kling.gg> | 2024-10-03 14:20:51 +0200 | 
| commit | a8226de3e53937b579705586a16ccc884b8efb5d (patch) | |
| tree | 63b2967b19772dd4ca3b44c486d5923948438a5d /userland | |
| parent | 9902f9a2b6c5030000e220841b5868158a0bc05d (diff) | |
libc: Add fdopendir()
Diffstat (limited to 'userland')
| -rw-r--r-- | userland/libc/dirent/opendir.c | 16 | 
1 files changed, 15 insertions, 1 deletions
diff --git a/userland/libc/dirent/opendir.c b/userland/libc/dirent/opendir.c index 7bfa562..efe8b6d 100644 --- a/userland/libc/dirent/opendir.c +++ b/userland/libc/dirent/opendir.c @@ -1,10 +1,24 @@  #include <dirent.h> +DIR *fdopendir(int fd) { +  DIR *rc = malloc(sizeof(DIR)); +  if (!rc) { +    return NULL; +  } +  rc->fd = fd; +  rc->dir_num = 0; +  return rc; +} +  DIR *opendir(const char *dirname) {    int fd = open(dirname, O_RDONLY, 0); -  if (-1 == fd) +  if (-1 == fd) {      return NULL; +  }    DIR *rc = malloc(sizeof(DIR)); +  if (!rc) { +    return NULL; +  }    rc->fd = fd;    rc->dir_num = 0;    return rc;  |