summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorLieuwe Rooijakkers <lieuwerooijakkers@gmail.com>2024-07-22 01:17:23 +0200
committerLieuwe Rooijakkers <lieuwerooijakkers@gmail.com>2024-07-22 12:22:09 +0200
commit0ec55999744b3092e68ea0f5b390dbed653fab30 (patch)
tree32b1f4d01b6e64ec446bd2d57ee489bf4613c3f0 /src/util
parentff6598dbdfeb7870b84ebdb81b0cc18c3c25a475 (diff)
betere foutmeldingen als een mapje geprobeerd geprojecteerd te worden
Diffstat (limited to 'src/util')
-rw-r--r--src/util/map.c5
-rw-r--r--src/util/map.h3
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);