diff --git a/file.c b/file.c index 3b5b366..82336b6 100644 --- a/file.c +++ b/file.c @@ -92,6 +92,7 @@ uint64_t fileTell(file_t *ctx) { #else #include +#include #include #include @@ -208,6 +209,10 @@ fread_buf_t fileReadWholeFP(file_t *ctx) { str_t fileReadWholeText(const char *fname) { file_t fp = fileOpen(fname, FILE_READ); + if(!fileIsValid(&fp)) { + err("couldn't open file %s -> %d", fname); + return strInit(); + } str_t contents = fileReadWholeFPText(&fp); fileClose(&fp); return contents;