diff options
author | Lieuwe Rooijakkers <lieuwerooijakkers@gmail.com> | 2024-07-23 00:23:06 +0200 |
---|---|---|
committer | Lieuwe Rooijakkers <lieuwerooijakkers@gmail.com> | 2024-08-02 22:38:00 +0200 |
commit | c4ccd4e0798a7ed9af6f86d9819b309575d418a0 (patch) | |
tree | f76183914b89d801b2853e78d4886cc00281dad0 /src/io/read_file.c | |
parent | 420e28845d5068d0c3b432ffc0d5fc80b7b7d7e2 (diff) |
file_to_filebuf: isdir output parameter
Diffstat (limited to 'src/io/read_file.c')
-rw-r--r-- | src/io/read_file.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/io/read_file.c b/src/io/read_file.c index 219a395..22e0286 100644 --- a/src/io/read_file.c +++ b/src/io/read_file.c @@ -60,18 +60,20 @@ static void *fd_to_mmap(const int fd, struct stat sb) { return addr; } -struct filebuf *file_to_filebuf(char *fname, int openOptions) { +struct filebuf *file_to_filebuf(char *fname, int openOptions, bool *isdir) { const int fd = open(fname, O_RDONLY); if (fd == -1) { return NULL; } - if (openOptions & O_NOALLOWMAP) { - goto sponge; - } - struct stat sb; if (fstat(fd, &sb) == -1) { + return NULL; + } + + if (isdir != NULL) *isdir = S_ISDIR(sb.st_mode); + + if (openOptions & O_NOALLOWMAP) { goto sponge; } |