]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
cli : fix : --rm is silent when input is stdin
authorYann Collet <cyan@fb.com>
Mon, 27 Feb 2017 23:57:50 +0000 (15:57 -0800)
committerYann Collet <cyan@fb.com>
Mon, 27 Feb 2017 23:57:50 +0000 (15:57 -0800)
previously, app would produce an error message, and stop.

NEWS
lib/compress/zstd_compress.c
programs/fileio.c

diff --git a/NEWS b/NEWS
index 96ff25fd75b608747fe08794ae86b998f20647a6..7ede5f70c43cde2d243d5088c966adc6602ffe91 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ v1.1.4
 cli : new : can compress in *.gz format, using --format=gzip command, by Przemyslaw Skibinski
 cli : new : advanced benchmark command --priority=rt
 cli : fix : write on sparse-enabled file systems in 32-bits mode, by @ds77
+cli : fix : --rm remains silent when input is stdin
 API : new : ZSTD_findFrameCompressedSize(), ZSTD_getFrameContentSize(), ZSTD_findDecompressedSize(), by Sean Purcell
 API : change : ZSTD_compress*() with srcSize==0 create an empty-frame of known size
 build:new : meson build system in contrib/meson, by Dima Krasner
index d684e6a0d848b18deed718bc437355bb53ebb093..ec758db00c37450781fecb79dd4af2efa43390ed 100644 (file)
@@ -248,7 +248,7 @@ static size_t ZSTD_continueCCtx(ZSTD_CCtx* cctx, ZSTD_parameters params, U64 fra
 typedef enum { ZSTDcrp_continue, ZSTDcrp_noMemset, ZSTDcrp_fullReset } ZSTD_compResetPolicy_e;
 
 /*! ZSTD_resetCCtx_advanced() :
-    note : 'params' must be validated */
+    note : @params must be validated */
 static size_t ZSTD_resetCCtx_advanced (ZSTD_CCtx* zc,
                                        ZSTD_parameters params, U64 frameContentSize,
                                        ZSTD_compResetPolicy_e const crp)
index 3cbd83ae098861850cdfab557d4701c2124800af..bc202cb24cbd0fa9ff39c38ee769a46be4b9b992 100644 (file)
@@ -549,7 +549,10 @@ static int FIO_compressFilename_srcFile(cRess_t ress,
     result = FIO_compressFilename_internal(ress, dstFileName, srcFileName, compressionLevel);
 
     fclose(ress.srcFile);
-    if (g_removeSrcFile && !result) { if (remove(srcFileName)) EXM_THROW(1, "zstd: %s: %s", srcFileName, strerror(errno)); } /* remove source file : --rm */
+    if (g_removeSrcFile /* --rm */ && !result && strcmp(srcFileName, stdinmark)) {
+        if (remove(srcFileName))
+            EXM_THROW(1, "zstd: %s: %s", srcFileName, strerror(errno));
+    }
     return result;
 }