From 60af95d9718a54c165937fb8f325e1d278b61565 Mon Sep 17 00:00:00 2001 From: inikep Date: Thu, 19 May 2016 10:29:49 +0200 Subject: [PATCH] fixed compression with -c with multiple files on Windows --- appveyor.yml | 2 +- programs/fileio.c | 3 ++- programs/tests/playTestsMSYS.sh | 14 +++++++------- programs/zstdcli.c | 5 +---- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index b79ef2a59..e002d89ef 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -95,5 +95,5 @@ test_script: projects\fuzzer_VS2012_%PLATFORM%_Release.exe %FUZZERTEST% && projects\fuzzer_VS2013_%PLATFORM%_Release.exe %FUZZERTEST% && projects\fuzzer_VS2015_%PLATFORM%_Release.exe %FUZZERTEST% && - zstd_VS2015_%PLATFORM%_Release.exe + REM zstd_VS2015_%PLATFORM%_Release.exe ) diff --git a/programs/fileio.c b/programs/fileio.c index b3f324ac6..638e63b57 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -71,7 +71,7 @@ #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) # include /* _O_BINARY */ # include /* _setmode, _isatty */ -# define SET_BINARY_MODE(file) { int unused = _setmode(_fileno(file), _O_BINARY); (void)unused; } +# define SET_BINARY_MODE(file) { if (_setmode(_fileno(file), _O_BINARY) == -1) perror("Cannot set _O_BINARY"); } #else # include /* isatty */ # define SET_BINARY_MODE(file) @@ -439,6 +439,7 @@ int FIO_compressMultipleFilenames(const char** inFileNamesTable, unsigned nbFile if (!strcmp(suffix, stdoutmark)) { unsigned u; ress.dstFile = stdout; + SET_BINARY_MODE(stdout); for (u=0; u tmp $ZSTD -f tmp # trivial compression case, creates tmp.zst $ZSTD -df tmp.zst # trivial decompression case (overwrites tmp) @@ -51,7 +51,7 @@ cp tmp tmp2.zst $ZSTD -df tmp2.zst && die "should have failed : wrong format" rm tmp2.zst -echo "\n**** frame concatenation **** " +echo -e "\n**** frame concatenation **** " echo "hello " > hello.tmp echo "world!" > world.tmp @@ -67,7 +67,7 @@ rm ./*.tmp ./*.zstd echo frame concatenation test completed -echo "\n**** dictionary tests **** " +echo -e "\n**** dictionary tests **** " ./datagen > tmpDict ./datagen -g1M | md5sum > tmp1 @@ -79,7 +79,7 @@ $ZSTD -d tmp -D tmpDict -of result fc xxhash.c result -echo "\n**** multiple files tests **** " +echo -e "\n**** multiple files tests **** " ./datagen -s1 > tmp1 2> /dev/null ./datagen -s2 -g100K > tmp2 2> /dev/null @@ -96,12 +96,12 @@ $ZSTD -c tmp1 tmp2 tmp3 > tmpall ls -ls tmp* echo "decompress tmpall* into stdout > tmpdec : " cp tmpall tmpall2 -# $ZSTD -dc tmpall* > tmpdec +$ZSTD -dc tmpall* > tmpdec ls -ls tmp* echo "compress multiple files including a missing one (notHere) : " $ZSTD -f tmp1 notHere tmp2 && die "missing file not detected!" -echo "\n**** integrity tests **** " +echo -e "\n**** integrity tests **** " echo "test one file (tmp1.zst) " $ZSTD -t tmp1.zst $ZSTD --test tmp1.zst @@ -110,7 +110,7 @@ $ZSTD -t *.zst echo "test good and bad files (*) " $ZSTD -t * && die "bad files not detected !" -echo "\n**** zstd round-trip tests **** " +echo -e "\n**** zstd round-trip tests **** " roundTripTest roundTripTest -g15K # TableID==3 diff --git a/programs/zstdcli.c b/programs/zstdcli.c index 310db7f88..8a8af3a2c 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -49,14 +49,11 @@ * OS-specific Includes **************************************/ #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) -# include /* _O_BINARY */ -# include /* _setmode, _isatty */ -# define SET_BINARY_MODE(file) _setmode(_fileno(file), _O_BINARY) +# include /* _isatty */ # define IS_CONSOLE(stdStream) _isatty(_fileno(stdStream)) #else extern int fileno(FILE *stream); /* triggers fileno() within on POSIX */ # include /* isatty */ -# define SET_BINARY_MODE(file) # define IS_CONSOLE(stdStream) isatty(fileno(stdStream)) #endif