]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
updated FIO_passThrough 470/head
authorPrzemyslaw Skibinski <inikep@gmail.com>
Mon, 5 Dec 2016 17:31:14 +0000 (18:31 +0100)
committerPrzemyslaw Skibinski <inikep@gmail.com>
Mon, 5 Dec 2016 17:31:14 +0000 (18:31 +0100)
programs/fileio.c
tests/Makefile

index f860145b480769c1052b54a84f9489661838c3ac..a493e97c57461143ba58a05bcd83c6de0d5c3b62 100644 (file)
@@ -589,15 +589,15 @@ static void FIO_fwriteSparseEnd(FILE* file, unsigned storedSkips)
 
 /** FIO_passThrough() : just copy input into output, for compatibility with gzip -df mode
     @return : 0 (no error) */
-static unsigned FIO_passThrough(FILE* foutput, FILE* finput, void* buffer, size_t bufferSize)
+static unsigned FIO_passThrough(FILE* foutput, FILE* finput, void* buffer, size_t bufferSize, size_t alreadyLoaded)
 {
     size_t const blockSize = MIN(64 KB, bufferSize);
     size_t readFromInput = 1;
     unsigned storedSkips = 0;
 
-    /* assumption : first 4 bytes already loaded (magic number detection), and stored within buffer */
-    { size_t const sizeCheck = fwrite(buffer, 1, 4, foutput);
-      if (sizeCheck != 4) EXM_THROW(50, "Pass-through write error"); }
+    /* assumption : ress->srcBufferLoaded bytes already loaded and stored within buffer */
+    { size_t const sizeCheck = fwrite(buffer, 1, alreadyLoaded, foutput);
+      if (sizeCheck != alreadyLoaded) EXM_THROW(50, "Pass-through write error"); }
 
     while (readFromInput) {
         readFromInput = fread(buffer, 1, blockSize, finput);
@@ -751,7 +751,7 @@ static int FIO_decompressSrcFile(dRess_t ress, const char* dstFileName, const ch
         } else {
             if (!ZSTD_isFrame(ress.srcBuffer, toRead)) {
                 if ((g_overwrite) && !strcmp (dstFileName, stdoutmark)) {  /* pass-through mode */
-                    unsigned const result = FIO_passThrough(ress.dstFile, srcFile, ress.srcBuffer, ress.srcBufferSize);
+                    unsigned const result = FIO_passThrough(ress.dstFile, srcFile, ress.srcBuffer, ress.srcBufferSize, ress.srcBufferLoaded);
                     if (fclose(srcFile)) EXM_THROW(32, "zstd: %s close error", srcFileName);  /* error should never happen */
                     return result;
                 } else {
index ad367595a332c5d403bbcf2af989129126f0d332..50bb057dc286f09f92a5ab6516022fb05d9da2a2 100644 (file)
@@ -202,6 +202,12 @@ test-gzstd: gzstd
        $(PRGDIR)/zstd -d README.md.gz test-zstd-speed.py.gz
        $(PRGDIR)/zstd -d zstd_gz.zst gz_zstd.gz
        diff -q zstd_gz gz_zstd
+       echo Hello World ZSTD | $(PRGDIR)/zstd -c - >hello.zst
+       echo Hello World GZIP | gzip -c - >hello.gz
+       echo Hello World TEXT >hello.txt
+       cat hello.zst hello.gz hello.txt >hello_zst_gz_txt.gz
+       $(PRGDIR)/zstd -dcf hello.*
+       $(PRGDIR)/zstd -dcf - <hello_zst_gz_txt.gz
 
 test-fullbench: fullbench datagen
        $(QEMU_SYS) ./fullbench -i1