mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:47:34 +00:00
LibC: Add function fdopendir
This adds the function fdopendir and refactors opendir so that opendir just opens a file descriptor and passes the file descriptor onto fdopendir.
This commit is contained in:
parent
51b6bd8d95
commit
78eba1271f
2 changed files with 8 additions and 0 deletions
|
@ -24,6 +24,13 @@ extern "C" {
|
|||
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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue