filed a bug in fileReadWholeText

This commit is contained in:
alessandrobason 2021-11-04 00:10:42 +00:00
parent aa39e2563d
commit 10e86abb44

5
file.c
View file

@ -92,6 +92,7 @@ uint64_t fileTell(file_t *ctx) {
#else #else
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
@ -208,6 +209,10 @@ fread_buf_t fileReadWholeFP(file_t *ctx) {
str_t fileReadWholeText(const char *fname) { str_t fileReadWholeText(const char *fname) {
file_t fp = fileOpen(fname, FILE_READ); 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); str_t contents = fileReadWholeFPText(&fp);
fileClose(&fp); fileClose(&fp);
return contents; return contents;