lib: c: io: implement standard FILE and DIR interfaces

This commit is contained in:
2026-03-25 20:21:12 +00:00
parent b975256cb9
commit 96784f611f
21 changed files with 599 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
#include "dir.h"
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
struct dirent *readdir(struct __opaque_dir *dirp)
{
int result = __libc_dir_move_next(dirp);
if (result < 0) {
dirp->d_flags |= DIR_ERR;
__set_errno(-result);
return NULL;
}
if (result > 0) {
return &dirp->d_current;
}
result = __libc_dir_refill(dirp);
if (result < 0) {
dirp->d_flags |= DIR_ERR;
__set_errno(-result);
return NULL;
}
if (!dirp->d_buf_datalen) {
return NULL;
}
return &dirp->d_current;
}