Added an error check when reading an input file
This commit is contained in:
@ -44,7 +44,7 @@ FILE *file_openrw(char* fileName, BOOL abortOnError)
|
||||
|
||||
/*
|
||||
* Function Name: fileNextChar(FILE* fp)
|
||||
* Description: Reads the file and returns next character, if file is null or its end of file, returns \<5C>.
|
||||
* Description: Reads the file and returns next character, if file is null or its end of file, returns \<5C>.
|
||||
*/
|
||||
char file_nextChar(FILE* fp)
|
||||
{
|
||||
@ -59,7 +59,7 @@ char file_nextChar(FILE* fp)
|
||||
|
||||
/*
|
||||
* Function Name: *fileNextLine(FILE *fp, char *buffer, int32_t bufferSize)
|
||||
* Description: Reads the file and returns next line, if file is null or its end of file, returns \<5C>.
|
||||
* Description: Reads the file and returns next line, if file is null or its end of file, returns \<5C>.
|
||||
*/
|
||||
char *file_nextLine(FILE *fp, char *buffer, int32_t bufferSize)
|
||||
{
|
||||
@ -76,7 +76,11 @@ char *file_nextLine(FILE *fp, char *buffer, int32_t bufferSize)
|
||||
void exitIfEmptyFile(FILE *file)
|
||||
{
|
||||
long savedOffset = ftell(file);
|
||||
fseek(file, 0, SEEK_END);
|
||||
if (fseek(file, 0, SEEK_END) != 0)
|
||||
{
|
||||
fprintf(stderr, "\nError moving the offset in an input file\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (ftell(file) == 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user