1
0
Fork 1

Fail gracefully if mime database is not present

This commit is contained in:
Drew DeVault 2020-10-28 12:49:47 -04:00
parent 077b96d3cc
commit a26573251b
1 changed files with 7 additions and 1 deletions

View File

@ -1,4 +1,5 @@
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
@ -29,7 +30,12 @@ mime_init()
mimedb = malloc(mimedb_sz * sizeof(struct mime_info));
FILE *f = fopen(MIMEDB, "r");
assert(f);
if (!f) {
fprintf(stderr, "Unable to open MIME database for reading: %s\n",
strerror(errno));
fprintf(stderr, "Is " MIMEDB " installed?\n");
assert(0);
}
char *line = NULL;
size_t n = 0;