]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[fileio] Don't call FIO_remove() on stdout or /dev/null 974/head
authorNick Terrell <terrelln@fb.com>
Fri, 5 Jan 2018 19:49:55 +0000 (11:49 -0800)
committerNick Terrell <terrelln@fb.com>
Fri, 5 Jan 2018 19:50:24 +0000 (11:50 -0800)
programs/fileio.c

index 71b87d4d5314898894bd7b9fccae22ca6bb1fc7b..887cbeb378cc93d5fe08a005945961dd2a603b34 100644 (file)
@@ -901,10 +901,10 @@ static int FIO_compressFilename_dstFile(cRess_t ress,
         DISPLAYLEVEL(1, "zstd: %s: %s \n", dstFileName, strerror(errno));
         result=1;
     }
-    if (result!=0) {  /* remove operation artefact */
-        if (FIO_remove(dstFileName))
-            EXM_THROW(1, "zstd: %s: %s", dstFileName, strerror(errno));
-    }
+    if ( (result != 0)  /* operation failure */
+      && strcmp(dstFileName, nulmark)      /* special case : don't remove() /dev/null */
+      && strcmp(dstFileName, stdoutmark) ) /* special case : don't remove() stdout */
+        FIO_remove(dstFileName); /* remove compression artefact; note don't do anything special if remove() fails */
     else if ( strcmp(dstFileName, stdoutmark)
            && strcmp(dstFileName, nulmark)
            && stat_result)