filed a bug in fileReadWholeText
This commit is contained in:
parent
aa39e2563d
commit
10e86abb44
1 changed files with 5 additions and 0 deletions
5
file.c
5
file.c
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue