]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed #260, reported by @amnilsson
authorYann Collet <yann.collet.73@gmail.com>
Mon, 25 Jul 2016 22:49:47 +0000 (00:49 +0200)
committerYann Collet <yann.collet.73@gmail.com>
Mon, 25 Jul 2016 22:49:47 +0000 (00:49 +0200)
programs/fileio.c
programs/fileio.h
programs/playTests.sh
programs/zstdcli.c

index 855385bef49c8a3bbf228b798b55cfbf418f9c98..538438cd9af0c5de5bc73607d54ab21b2156939a 100644 (file)
@@ -180,7 +180,7 @@ static FILE* FIO_openSrcFile(const char* srcFileName)
     return f;
 }
 
-
+/* `dstFileName must` be non-NULL */
 static FILE* FIO_openDstFile(const char* dstFileName)
 {
     FILE* f;
index 4a4f3d226a6514915892bf07d35ea4bee82d8293..06d977d638983a1eb3fbb2458849150e870e2524 100644 (file)
@@ -31,7 +31,6 @@ extern "C" {
 /* *************************************
 *  Special i/o constants
 **************************************/
-#define nullString "null"
 #define stdinmark "stdin"
 #define stdoutmark "stdout"
 #ifdef _WIN32
index b19c2bc520904e52fb026c9ef7d1f8451b90c8fa..6939aa8170515b2105ff871f56ba9ce3ea109fae 100755 (executable)
@@ -206,6 +206,9 @@ $ECHO "test multiple files (*.zst) "
 $ZSTD -t *.zst
 $ECHO "test good and bad files (*) "
 $ZSTD -t * && die "bad files not detected !"
+$ECHO "test --rm and --test combined "
+$ZSTD -t --rm tmp1.zst
+ls -ls tmp1.zst  # check file is still present
 
 
 $ECHO "\n**** zstd round-trip tests **** "
index 344d3c88ed27167fde4dc99d121efa26620bb666..30e0d01b7366fb30b84890aebd755db26227e3eb 100644 (file)
@@ -206,6 +206,7 @@ int main(int argCount, const char** argv)
     int argNb,
         bench=0,
         decode=0,
+        testmode=0,
         forceStdout=0,
         main_pause=0,
         nextEntryIsDictionary=0,
@@ -273,7 +274,7 @@ int main(int argCount, const char** argv)
             if (!strcmp(argument, "--no-dictID")) { FIO_setDictIDFlag(0); continue; }
             if (!strcmp(argument, "--sparse")) { FIO_setSparseWrite(2); continue; }
             if (!strcmp(argument, "--no-sparse")) { FIO_setSparseWrite(0); continue; }
-            if (!strcmp(argument, "--test")) { decode=1; outFileName=nulmark; FIO_overwriteMode(); continue; }
+            if (!strcmp(argument, "--test")) { testmode=1; decode=1; continue; }
             if (!strcmp(argument, "--train")) { dictBuild=1; outFileName=g_defaultDictName; continue; }
             if (!strcmp(argument, "--maxdict")) { nextArgumentIsMaxDict=1; continue; }
             if (!strcmp(argument, "--dictID")) { nextArgumentIsDictID=1; continue; }
@@ -337,7 +338,7 @@ int main(int argCount, const char** argv)
                     case 'C': argument++; FIO_setChecksumFlag(2); break;
 
                         /* test compressed file */
-                    case 't': decode=1; outFileName=nulmark; argument++; break;
+                    case 't': testmode=1; decode=1; argument++; break;
 
                         /* destination file name */
                     case 'o': nextArgumentIsOutFileName=1; argument++; break;
@@ -503,6 +504,7 @@ int main(int argCount, const char** argv)
 #endif
     {  /* decompression */
 #ifndef ZSTD_NODECOMPRESS
+        if (testmode) { outFileName=nulmark; FIO_setRemoveSrcFile(0); } /* test mode */
         if (filenameIdx==1 && outFileName)
             operationResult = FIO_decompressFilename(outFileName, filenameTable[0], dictFileName);
         else