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
+30
View File
@@ -0,0 +1,30 @@
#include "dir.h"
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
extern struct __opaque_dir *opendir(const char *name)
{
struct __opaque_dir *out = malloc(sizeof *out);
if (!out) {
__set_errno(ENOMEM);
return NULL;
}
memset(out, 0x0, sizeof *out);
int fd = open(name, O_RDONLY | O_DIRECTORY);
if (fd < 0) {
free(out);
return NULL;
}
out->d_flags = 0;
out->d_fd = fd;
return out;
}