diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/map.c | 5 | ||||
-rw-r--r-- | src/util/map.h | 3 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/util/map.c b/src/util/map.c index 27e1c04..6a1faf1 100644 --- a/src/util/map.c +++ b/src/util/map.c @@ -9,7 +9,9 @@ #include "map.h" -struct map *open_map(const char *fname) { +struct map *open_map(const char *fname, bool *isdir) { + if (isdir != NULL) *isdir = false; + int fd = open(fname, O_RDONLY); struct stat sb; @@ -21,6 +23,7 @@ struct map *open_map(const char *fname) { char *addr = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0); if (addr == MAP_FAILED) { //fprintf(stderr, "Kon bestand niet projecteren in geheugen\n"); + if (isdir != NULL) *isdir = S_ISDIR(sb.st_mode); return NULL; } diff --git a/src/util/map.h b/src/util/map.h index 67beb9c..14a48e1 100644 --- a/src/util/map.h +++ b/src/util/map.h @@ -1,3 +1,4 @@ +#include <stdbool.h> #include <sys/stat.h> struct map { @@ -7,5 +8,5 @@ struct map { int fd; }; -struct map *open_map(const char *fname); +struct map *open_map(const char *fname, bool *isdir); void close_map(struct map *m); |