X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=shared%2Fread_file.cpp;h=77a23fdff0b07e181e506c9aa4b6d04357b4d297;hb=9ffd4f03f314cc6e0254449593def95c9bc203d6;hp=2310303dd3345738e0df33710fd72345371d1df1;hpb=eeda8995329601f9f4e35047358400833eeae68e;p=nageru diff --git a/shared/read_file.cpp b/shared/read_file.cpp index 2310303..77a23fd 100644 --- a/shared/read_file.cpp +++ b/shared/read_file.cpp @@ -17,21 +17,25 @@ string read_file(const string &filename, const unsigned char *start, const size_ } perror(filename.c_str()); - exit(1); + abort(); } int ret = fseek(fp, 0, SEEK_END); if (ret == -1) { perror("fseek(SEEK_END)"); - exit(1); + abort(); } int disk_size = ftell(fp); + if (disk_size == -1) { + perror("ftell"); + abort(); + } ret = fseek(fp, 0, SEEK_SET); if (ret == -1) { perror("fseek(SEEK_SET)"); - exit(1); + abort(); } string str; @@ -39,12 +43,12 @@ string read_file(const string &filename, const unsigned char *start, const size_ ret = fread(&str[0], disk_size, 1, fp); if (ret == -1) { perror("fread"); - exit(1); + abort(); } if (ret == 0) { fprintf(stderr, "Short read when trying to read %d bytes from %s\n", disk_size, filename.c_str()); - exit(1); + abort(); } fclose(fp);