summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibC/dirent.cpp7
-rw-r--r--Userland/Libraries/LibC/dirent.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/dirent.cpp b/Userland/Libraries/LibC/dirent.cpp
index 7475d22519..3447b9d370 100644
--- a/Userland/Libraries/LibC/dirent.cpp
+++ b/Userland/Libraries/LibC/dirent.cpp
@@ -26,6 +26,13 @@ DIR* opendir(const char* name)
int fd = open(name, O_RDONLY | O_DIRECTORY);
if (fd == -1)
return nullptr;
+ return fdopendir(fd);
+}
+
+DIR* fdopendir(int fd)
+{
+ if (fd == -1)
+ return nullptr;
DIR* dirp = (DIR*)malloc(sizeof(DIR));
dirp->fd = fd;
dirp->buffer = nullptr;
diff --git a/Userland/Libraries/LibC/dirent.h b/Userland/Libraries/LibC/dirent.h
index e78114bb6d..1e3f8534cc 100644
--- a/Userland/Libraries/LibC/dirent.h
+++ b/Userland/Libraries/LibC/dirent.h
@@ -27,6 +27,7 @@ struct __DIR {
};
typedef struct __DIR DIR;
+DIR* fdopendir(int fd);
DIR* opendir(const char* name);
int closedir(DIR*);
void rewinddir(DIR*);