Merge pull request #1160 from GeorgeLu97/formatzstd

Added --format=zstd
This commit is contained in:
Yann Collet 2018-06-01 12:46:03 -07:00 committed by GitHub
commit 2b5b2ea7df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View File

@ -164,7 +164,8 @@ the last one takes effect.
* `--format=FORMAT`: * `--format=FORMAT`:
compress and decompress in other formats. If compiled with compress and decompress in other formats. If compiled with
support, zstd can compress to or decompress from other compression algorithm support, zstd can compress to or decompress from other compression algorithm
formats. Possibly available options are `gzip`, `xz`, `lzma`, and `lz4`. formats. Possibly available options are `zstd`, `gzip`, `xz`, `lzma`, and `lz4`.
If no such format is provided, `zstd` is the default.
* `-h`/`-H`, `--help`: * `-h`/`-H`, `--help`:
display help/long help and exit display help/long help and exit
* `-V`, `--version`: * `-V`, `--version`:

View File

@ -145,6 +145,7 @@ static int usage_advanced(const char* programName)
#ifdef UTIL_HAS_CREATEFILELIST #ifdef UTIL_HAS_CREATEFILELIST
DISPLAY( " -r : operate recursively on directories \n"); DISPLAY( " -r : operate recursively on directories \n");
#endif #endif
DISPLAY( "--format=zstd : compress files to the .zstd format (default) \n");
#ifdef ZSTD_GZCOMPRESS #ifdef ZSTD_GZCOMPRESS
DISPLAY( "--format=gzip : compress files to the .gz format \n"); DISPLAY( "--format=gzip : compress files to the .gz format \n");
#endif #endif
@ -500,6 +501,7 @@ int main(int argCount, const char* argv[])
if (!strcmp(argument, "--rm")) { FIO_setRemoveSrcFile(1); continue; } if (!strcmp(argument, "--rm")) { FIO_setRemoveSrcFile(1); continue; }
if (!strcmp(argument, "--priority=rt")) { setRealTimePrio = 1; continue; } if (!strcmp(argument, "--priority=rt")) { setRealTimePrio = 1; continue; }
if (!strcmp(argument, "--single-thread")) { nbWorkers = 0; singleThread = 1; continue; } if (!strcmp(argument, "--single-thread")) { nbWorkers = 0; singleThread = 1; continue; }
if (!strcmp(argument, "--format=zstd")) { suffix = ZSTD_EXTENSION; FIO_setCompressionType(FIO_zstdCompression); continue; }
#ifdef ZSTD_GZCOMPRESS #ifdef ZSTD_GZCOMPRESS
if (!strcmp(argument, "--format=gzip")) { suffix = GZ_EXTENSION; FIO_setCompressionType(FIO_gzipCompression); continue; } if (!strcmp(argument, "--format=gzip")) { suffix = GZ_EXTENSION; FIO_setCompressionType(FIO_gzipCompression); continue; }
#endif #endif

View File

@ -485,6 +485,12 @@ $ZSTD -bi0 --fast tmp1
$ECHO "with recursive and quiet modes" $ECHO "with recursive and quiet modes"
$ZSTD -rqi1b1e2 tmp1 $ZSTD -rqi1b1e2 tmp1
$ECHO "\n===> zstd compatibility tests "
./datagen > tmp
rm -f tmp.zst
$ZSTD --format=zstd -f tmp
test -f tmp.zst
$ECHO "\n===> gzip compatibility tests " $ECHO "\n===> gzip compatibility tests "
@ -522,6 +528,12 @@ else
$ECHO "gzip mode not supported" $ECHO "gzip mode not supported"
fi fi
if [ $GZIPMODE -eq 1 ]; then
./datagen > tmp
rm -f tmp.zst
$ZSTD --format=gzip --format=zstd -f tmp
test -f tmp.zst
fi
$ECHO "\n===> xz compatibility tests " $ECHO "\n===> xz compatibility tests "