From 0ec55999744b3092e68ea0f5b390dbed653fab30 Mon Sep 17 00:00:00 2001 From: Lieuwe Rooijakkers Date: Mon, 22 Jul 2024 01:17:23 +0200 Subject: betere foutmeldingen als een mapje geprobeerd geprojecteerd te worden --- src/util/map.c | 5 ++++- src/util/map.h | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/util') 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 #include 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); -- cgit v1.2.3-70-g09d2