]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
improved #232 fix 519/head
authorPrzemyslaw Skibinski <inikep@gmail.com>
Wed, 25 Jan 2017 12:11:26 +0000 (13:11 +0100)
committerPrzemyslaw Skibinski <inikep@gmail.com>
Wed, 25 Jan 2017 12:11:26 +0000 (13:11 +0100)
programs/fileio.c

index 9c3c2b7af69c0088a7584d999a3cb7a78dbd6f72..430cc07ebd846bcdeca4ab801f173ad961f49262 100644 (file)
@@ -138,6 +138,10 @@ static FILE* FIO_openSrcFile(const char* srcFileName)
         f = stdin;
         SET_BINARY_MODE(stdin);
     } else {
+        if (!UTIL_doesFileExists(srcFileName)) {
+            DISPLAYLEVEL(1, "zstd: %s is not a regular file -- ignored \n", srcFileName);
+            return NULL;
+        }
         f = fopen(srcFileName, "rb");
         if ( f==NULL ) DISPLAYLEVEL(1, "zstd: %s: %s \n", srcFileName, strerror(errno));
     }
@@ -361,10 +365,6 @@ static int FIO_compressFilename_srcFile(cRess_t ress,
         DISPLAYLEVEL(1, "zstd: %s is a directory -- ignored \n", srcFileName);
         return 1;
     }
-    if (!UTIL_doesFileExists(srcFileName)) {
-        DISPLAYLEVEL(1, "zstd: %s is not a regular file -- ignored \n", srcFileName);
-        return 1;
-    }
 
     ress.srcFile = FIO_openSrcFile(srcFileName);
     if (!ress.srcFile) return 1;   /* srcFile could not be opened */
@@ -724,10 +724,6 @@ static int FIO_decompressSrcFile(dRess_t ress, const char* dstFileName, const ch
         DISPLAYLEVEL(1, "zstd: %s is a directory -- ignored \n", srcFileName);
         return 1;
     }
-    if (!UTIL_doesFileExists(srcFileName)) {
-        DISPLAYLEVEL(1, "zstd: %s is not a regular file -- ignored \n", srcFileName);
-        return 1;
-    }
 
     srcFile = FIO_openSrcFile(srcFileName);
     if (srcFile==0) return 1;