Added opendir and readdir.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "sourcefs.h"
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -9,6 +10,8 @@ static struct source_files_handle {
|
||||
int root_fd;
|
||||
} handle;
|
||||
|
||||
void source_fname_translate(const char *filename) {}
|
||||
|
||||
int source_init(const char *root_path) {
|
||||
int root_fd = open(root_path, O_PATH);
|
||||
|
||||
@@ -26,3 +29,12 @@ int source_stat(const char *restrict pathname, struct stat *restrict statbuf) {
|
||||
int statret = fstatat(handle.root_fd, pathname, statbuf, 0);
|
||||
return statret;
|
||||
}
|
||||
|
||||
DIR *source_opendir(const char *filename) {
|
||||
int fd = openat(handle.root_fd, filename, NULL);
|
||||
DIR *dir_pointer = fdopendir(fd);
|
||||
return dir_pointer;
|
||||
}
|
||||
|
||||
// Just regular readdir in disguise.
|
||||
struct dirent *source_readdir(DIR *dirp) { return readdir(dirp); }
|
||||
|
Reference in New Issue
Block a user