added error check for when file could not be opened

This commit is contained in:
Paul Cruz
2017-06-21 12:37:23 -07:00
parent 74a725da69
commit 6f5fe71041
+6 -1
View File
@@ -875,13 +875,14 @@ typedef struct {
/* /*
* Reads information from file, stores in *info * Reads information from file, stores in *info
* if successful, returns 0, returns 1 for frame analysis error, returns 2 for file not compressed with zstd * if successful, returns 0, returns 1 for frame analysis error, returns 2 for file not compressed with zstd
* returns 3 for cases in which file could not be opened.
*/ */
static int getFileInfo(fileInfo_t* info, const char* inFileName){ static int getFileInfo(fileInfo_t* info, const char* inFileName){
int detectError = 0; int detectError = 0;
FILE* const srcFile = FIO_openSrcFile(inFileName); FILE* const srcFile = FIO_openSrcFile(inFileName);
if (srcFile == NULL) { if (srcFile == NULL) {
DISPLAY("Error: could not open source file %s\n", inFileName); DISPLAY("Error: could not open source file %s\n", inFileName);
return 1; return 3;
} }
info->compressedSize = (unsigned long long)UTIL_getFileSize(inFileName); info->compressedSize = (unsigned long long)UTIL_getFileSize(inFileName);
/* begin analyzing frame */ /* begin analyzing frame */
@@ -1056,6 +1057,10 @@ static int FIO_listFile(const char* inFileName, int displayLevel, unsigned fileN
} }
return 1; return 1;
} }
else if (error == 3) {
/* error occurred with opening the file */
return 1;
}
displayInfo(inFileName, &info, displayLevel); displayInfo(inFileName, &info, displayLevel);
return error; return error;
} }