]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
added error check for when file could not be opened
authorPaul Cruz <paulcruz74@fb.com>
Wed, 21 Jun 2017 19:37:23 +0000 (12:37 -0700)
committerPaul Cruz <paulcruz74@fb.com>
Wed, 21 Jun 2017 19:37:23 +0000 (12:37 -0700)
programs/fileio.c

index a0510f62d9c7d003a853fc3584d6dda1062ea8af..634a888c18f8ba9fa2e30aaa5fcd153a19d3327c 100644 (file)
@@ -875,13 +875,14 @@ typedef struct {
 /*
  * 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
+ * returns 3 for cases in which file could not be opened.
  */
 static int getFileInfo(fileInfo_t* info, const char* inFileName){
     int detectError = 0;
     FILE* const srcFile = FIO_openSrcFile(inFileName);
     if (srcFile == NULL) {
         DISPLAY("Error: could not open source file %s\n", inFileName);
-        return 1;
+        return 3;
     }
     info->compressedSize = (unsigned long long)UTIL_getFileSize(inFileName);
     /* begin analyzing frame */
@@ -1056,6 +1057,10 @@ static int FIO_listFile(const char* inFileName, int displayLevel, unsigned fileN
             }
             return 1;
         }
+        else if (error == 3) {
+            /* error occurred with opening the file */
+            return 1;
+        }
         displayInfo(inFileName, &info, displayLevel);
         return error;
     }