mirror of
https://github.com/facebook/zstd.git
synced 2025-07-29 11:21:22 +03:00
initial commit
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) Yann Collet, Facebook, Inc.
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under both the BSD-style license (found in the
|
||||
@ -27,8 +27,8 @@
|
||||
/*-************************************
|
||||
* Dependencies
|
||||
**************************************/
|
||||
#include "platform.h" /* IS_CONSOLE, PLATFORM_POSIX_VERSION */
|
||||
#include "util.h" /* UTIL_HAS_CREATEFILELIST, UTIL_createFileList */
|
||||
#include "platform.h" /* PLATFORM_POSIX_VERSION */
|
||||
#include "util.h" /* UTIL_HAS_CREATEFILELIST, UTIL_createFileList, UTIL_isConsole */
|
||||
#include <stdlib.h> /* getenv */
|
||||
#include <string.h> /* strcmp, strlen */
|
||||
#include <stdio.h> /* fprintf(), stdin, stdout, stderr */
|
||||
@ -52,12 +52,12 @@
|
||||
/*-************************************
|
||||
* Constants
|
||||
**************************************/
|
||||
#define COMPRESSOR_NAME "zstd command line interface"
|
||||
#define COMPRESSOR_NAME "Zstandard CLI"
|
||||
#ifndef ZSTD_VERSION
|
||||
# define ZSTD_VERSION "v" ZSTD_VERSION_STRING
|
||||
#endif
|
||||
#define AUTHOR "Yann Collet"
|
||||
#define WELCOME_MESSAGE "*** %s %i-bits %s, by %s ***\n", COMPRESSOR_NAME, (int)(sizeof(size_t)*8), ZSTD_VERSION, AUTHOR
|
||||
#define WELCOME_MESSAGE "*** %s (%i-bit) %s, by %s ***\n", COMPRESSOR_NAME, (int)(sizeof(size_t)*8), ZSTD_VERSION, AUTHOR
|
||||
|
||||
#define ZSTD_ZSTDMT "zstdmt"
|
||||
#define ZSTD_UNZSTD "unzstd"
|
||||
@ -143,160 +143,174 @@ static int exeNameMatch(const char* exeName, const char* test)
|
||||
*/
|
||||
static void usage(FILE* f, const char* programName)
|
||||
{
|
||||
DISPLAY_F(f, "Usage: %s [OPTION]... [FILE]... [-o file]\n", programName);
|
||||
DISPLAY_F(f, "Compress or uncompress FILEs (with no FILE or when FILE is `-`, read from standard input).\n\n");
|
||||
DISPLAY_F(f, " -o file result stored into `file` (only 1 output file)\n");
|
||||
#ifndef ZSTD_NOCOMPRESS
|
||||
DISPLAY_F(f, " -1 .. -%d compression level (faster .. better; default: %d)\n", ZSTDCLI_CLEVEL_MAX, ZSTDCLI_CLEVEL_DEFAULT);
|
||||
#endif
|
||||
#ifndef ZSTD_NODECOMPRESS
|
||||
DISPLAY_F(f, " -d, --decompress decompression\n");
|
||||
#endif
|
||||
DISPLAY_F(f, " -f, --force disable input and output checks. Allows overwriting existing files,\n");
|
||||
DISPLAY_F(f, " input from console, output to stdout, operating on links,\n");
|
||||
DISPLAY_F(f, " block devices, etc. During decompression and when the output\n");
|
||||
DISPLAY_F(f, " destination is stdout, pass-through unrecognized formats as-is.\n");
|
||||
DISPLAY_F(f, " --rm remove source file(s) after successful de/compression\n");
|
||||
DISPLAY_F(f, " -k, --keep preserve source file(s) (default) \n");
|
||||
DISPLAY_F(f, "Compress or decompress the INPUT file(s); reads from STDIN if INPUT is `-` or not provided.\n\n");
|
||||
DISPLAY_F(f, "Usage: %s [OPTIONS...] [INPUT... | -] [-o OUTPUT]\n\n", programName);
|
||||
DISPLAY_F(f, "Options:\n");
|
||||
DISPLAY_F(f, " -o OUTPUT Write output to a single file, OUTPUT.\n");
|
||||
DISPLAY_F(f, " -k, --keep Preserve INPUT file(s). [Default] \n");
|
||||
DISPLAY_F(f, " --rm Remove INPUT file(s) after successful (de)compression.\n");
|
||||
#ifdef ZSTD_GZCOMPRESS
|
||||
if (exeNameMatch(programName, ZSTD_GZ)) { /* behave like gzip */
|
||||
DISPLAY_F(f, " -n, --no-name do not store original filename when compressing\n");
|
||||
DISPLAY_F(f, " -n, --no-name Do not store original filename when compressing.\n\n");
|
||||
}
|
||||
#endif
|
||||
DISPLAY_F(f, " -D DICT use DICT as Dictionary for compression or decompression\n");
|
||||
DISPLAY_F(f, " -h display usage and exit\n");
|
||||
DISPLAY_F(f, " -H,--help display long help and exit\n");
|
||||
DISPLAY_F(f, "\n");
|
||||
#ifndef ZSTD_NOCOMPRESS
|
||||
DISPLAY_F(f, " -# Desired compression level, where `#` is a number between 1 and %d;\n", ZSTDCLI_CLEVEL_MAX);
|
||||
DISPLAY_F(f, " lower numbers provide faster compression, higher numbers yield\n");
|
||||
DISPLAY_F(f, " better compression ratios. [Default: %d]\n\n", ZSTDCLI_CLEVEL_DEFAULT);
|
||||
#endif
|
||||
#ifndef ZSTD_NODECOMPRESS
|
||||
DISPLAY_F(f, " -d, --decompress Perform decompression.\n");
|
||||
#endif
|
||||
DISPLAY_F(f, " -D DICT Use DICT as the dictionary for compression or decompression.\n\n");
|
||||
DISPLAY_F(f, " -f, --force Disable input and output checks. Allows overwriting existing files,\n");
|
||||
DISPLAY_F(f, " receiving input from the console, printing ouput to STDOUT, and\n");
|
||||
DISPLAY_F(f, " operating on links, block devices, etc. Unrecognized formats will be\n");
|
||||
DISPLAY_F(f, " passed-through through as-is.\n\n");
|
||||
|
||||
DISPLAY_F(f, " -h Display short usage and exit.\n");
|
||||
DISPLAY_F(f, " -H, --help Display full help and exit.\n");
|
||||
DISPLAY_F(f, " -V, --version Display the program version and exit.\n");
|
||||
DISPLAY_F(f, "\n");
|
||||
}
|
||||
|
||||
static void usage_advanced(const char* programName)
|
||||
{
|
||||
DISPLAYOUT(WELCOME_MESSAGE);
|
||||
DISPLAYOUT("\n");
|
||||
usage(stdout, programName);
|
||||
DISPLAYOUT("Advanced options :\n");
|
||||
DISPLAYOUT(" -V, --version display Version number and exit\n");
|
||||
DISPLAYOUT("Advanced options:\n");
|
||||
DISPLAYOUT(" -c, --stdout Write to STDOUT (even if it is a console) and keep the INPUT file(s).\n\n");
|
||||
|
||||
DISPLAYOUT(" -c, --stdout write to standard output (even if it is the console), keep original file\n");
|
||||
|
||||
DISPLAYOUT(" -v, --verbose verbose mode; specify multiple times to increase verbosity\n");
|
||||
DISPLAYOUT(" -q, --quiet suppress warnings; specify twice to suppress errors too\n");
|
||||
DISPLAYOUT(" --[no-]progress forcibly display, or never display the progress counter\n");
|
||||
DISPLAYOUT(" note: any (de)compressed output to terminal will mix with progress counter text\n");
|
||||
DISPLAYOUT(" -v, --verbose Enable verbose output; pass multiple times to increase verbosity.\n");
|
||||
DISPLAYOUT(" -q, --quiet Suppress warnings; pass twice to suppress errors.\n");
|
||||
#ifndef ZSTD_NOTRACE
|
||||
DISPLAYOUT(" --trace LOG Log tracing information to LOG.\n");
|
||||
#endif
|
||||
DISPLAYOUT("\n");
|
||||
DISPLAYOUT(" --[no-]progress Forcibly show/hide the progress counter. NOTE: Any (de)compressed\n");
|
||||
DISPLAYOUT(" output to terminal will mix with progress counter text.\n\n");
|
||||
|
||||
#ifdef UTIL_HAS_CREATEFILELIST
|
||||
DISPLAYOUT(" -r operate recursively on directories\n");
|
||||
DISPLAYOUT(" --filelist FILE read list of files to operate upon from FILE\n");
|
||||
DISPLAYOUT(" --output-dir-flat DIR : processed files are stored into DIR\n");
|
||||
DISPLAYOUT(" -r Operate recursively on directories.\n");
|
||||
DISPLAYOUT(" --filelist LIST Read a list of files to operate on from LIST.\n");
|
||||
DISPLAYOUT(" --output-dir-flat DIR Store processed files in DIR.\n");
|
||||
#endif
|
||||
|
||||
#ifdef UTIL_HAS_MIRRORFILELIST
|
||||
DISPLAYOUT(" --output-dir-mirror DIR : processed files are stored into DIR respecting original directory structure\n");
|
||||
DISPLAYOUT(" --output-dir-mirror DIR Store processed files in DIR, respecting original directory structure.\n");
|
||||
#endif
|
||||
if (AIO_supported())
|
||||
DISPLAYOUT(" --[no-]asyncio use asynchronous IO (default: enabled)\n");
|
||||
DISPLAYOUT(" --[no-]asyncio Use asynchronous IO. [Default: Enabled]\n");
|
||||
|
||||
DISPLAYOUT("\n");
|
||||
#ifndef ZSTD_NOCOMPRESS
|
||||
DISPLAYOUT(" --[no-]check during compression, add XXH64 integrity checksum to frame (default: enabled)\n");
|
||||
DISPLAYOUT(" --[no-]check Add XXH64 integrity checksums during compression. [Default: Add, Validate]\n");
|
||||
#ifndef ZSTD_NODECOMPRESS
|
||||
DISPLAYOUT(" if specified with -d, decompressor will ignore/validate checksums in compressed frame (default: validate)\n");
|
||||
DISPLAYOUT(" If `-d` is present, ignore/validate checksums during decompression.\n");
|
||||
#endif
|
||||
#else
|
||||
#ifdef ZSTD_NOCOMPRESS
|
||||
DISPLAYOUT(" --[no-]check during decompression, ignore/validate checksums in compressed frame (default: validate)");
|
||||
DISPLAYOUT(" --[no-]check Ignore/validate checksums during decompression. [Default: Validate]");
|
||||
#endif
|
||||
DISPLAYOUT("\n");
|
||||
#endif /* ZSTD_NOCOMPRESS */
|
||||
|
||||
#ifndef ZSTD_NOTRACE
|
||||
DISPLAYOUT(" --trace FILE log tracing information to FILE\n");
|
||||
#endif
|
||||
DISPLAYOUT(" -- all arguments after \"--\" are treated as files\n");
|
||||
DISPLAYOUT("\n");
|
||||
DISPLAYOUT(" -- Treat remaining arguments after `--` as files.\n");
|
||||
|
||||
#ifndef ZSTD_NOCOMPRESS
|
||||
DISPLAYOUT("\n");
|
||||
DISPLAYOUT("Advanced compression options :\n");
|
||||
DISPLAYOUT(" --ultra enable levels beyond %i, up to %i (requires more memory)\n", ZSTDCLI_CLEVEL_MAX, ZSTD_maxCLevel());
|
||||
DISPLAYOUT(" --fast[=#] switch to very fast compression levels (default: %u)\n", 1);
|
||||
DISPLAYOUT("Advanced compression options:\n");
|
||||
DISPLAYOUT(" --ultra Enable levels beyond %i, up to %i; requires more memory.\n", ZSTDCLI_CLEVEL_MAX, ZSTD_maxCLevel());
|
||||
DISPLAYOUT(" --fast[=#] Use to very fast compression levels. [Default: %u]\n", 1);
|
||||
#ifdef ZSTD_GZCOMPRESS
|
||||
if (exeNameMatch(programName, ZSTD_GZ)) { /* behave like gzip */
|
||||
DISPLAYOUT(" --best compatibility alias for -9 \n");
|
||||
DISPLAYOUT(" --no-name do not store original filename when compressing\n");
|
||||
DISPLAYOUT(" --best Compatibility alias for `-9`.\n");
|
||||
}
|
||||
#endif
|
||||
DISPLAYOUT(" --long[=#] enable long distance matching with given window log (default: %u)\n", g_defaultMaxWindowLog);
|
||||
DISPLAYOUT(" --patch-from=FILE : specify the file to be used as a reference point for zstd's diff engine. \n");
|
||||
DISPLAYOUT(" --adapt dynamically adapt compression level to I/O conditions\n");
|
||||
DISPLAYOUT(" --adapt Dynamically adapt compression level to I/O conditions.\n");
|
||||
DISPLAYOUT(" --long[=#] Enable long distance matching with window log #. [Default: %u]\n", g_defaultMaxWindowLog);
|
||||
DISPLAYOUT(" --patch-from=REF Use REF as the reference point for Zstandard's diff engine. \n\n");
|
||||
# ifdef ZSTD_MULTITHREAD
|
||||
DISPLAYOUT(" -T# spawn # compression threads (default: 1, 0==# cores) \n");
|
||||
DISPLAYOUT(" -B# select size of each job (default: 0==automatic) \n");
|
||||
DISPLAYOUT(" --single-thread use a single thread for both I/O and compression (result slightly different than -T1) \n");
|
||||
DISPLAYOUT(" --auto-threads={physical,logical} : use either physical cores or logical cores as default when specifying -T0 (default: physical)\n");
|
||||
DISPLAYOUT(" --rsyncable compress using a rsync-friendly method (-B sets block size) \n");
|
||||
DISPLAYOUT(" -T# Spawn # compression threads. [Default: 1; pass 0 for core count.]\n");
|
||||
DISPLAYOUT(" --single-thread Share a single thread for I/O and compression (slightly different than `-T1`).\n");
|
||||
DISPLAYOUT(" --auto-threads={physical|logical}\n");
|
||||
DISPLAYOUT(" Use physical/logical cores when using `-T0`. [Default: Physical]\n\n");
|
||||
DISPLAYOUT(" -B# Set job size to #. [Default: 0 (automatic)]\n");
|
||||
DISPLAYOUT(" --rsyncable Compress using a rsync-friendly method (`-B` sets block size). \n");
|
||||
DISPLAYOUT("\n");
|
||||
# endif
|
||||
DISPLAYOUT(" --exclude-compressed : only compress files that are not already compressed \n");
|
||||
DISPLAYOUT(" --stream-size=# specify size of streaming input from `stdin` \n");
|
||||
DISPLAYOUT(" --size-hint=# optimize compression parameters for streaming input of approximately this size \n");
|
||||
DISPLAYOUT(" --target-compressed-block-size=# : generate compressed block of approximately targeted size \n");
|
||||
DISPLAYOUT(" --no-dictID don't write dictID into header (dictionary compression only)\n");
|
||||
DISPLAYOUT(" --[no-]compress-literals : force (un)compressed literals\n");
|
||||
DISPLAYOUT(" --[no-]row-match-finder : force enable/disable usage of fast row-based matchfinder for greedy, lazy, and lazy2 strategies\n");
|
||||
DISPLAYOUT(" --exclude-compressed Only compress files that are not already compressed.\n\n");
|
||||
|
||||
DISPLAYOUT(" --format=zstd compress files to the .zst format (default)\n");
|
||||
DISPLAYOUT(" --stream-size=# Specify size of streaming input from STDIN.\n");
|
||||
DISPLAYOUT(" --size-hint=# Optimize compression parameters for streaming input of approximately size #.\n");
|
||||
DISPLAYOUT(" --target-compressed-block-size=#\n");
|
||||
DISPLAYOUT(" Generate compressed blocks of approximately # size.\n\n");
|
||||
DISPLAYOUT(" --no-dictID Don't write `dictID` into the header (dictionary compression only).\n");
|
||||
DISPLAYOUT(" --[no-]compress-literals Force (un)compressed literals.\n");
|
||||
DISPLAYOUT(" --[no-]row-match-finder Explicitly enable/disable the fast, row-based matchfinder for\n");
|
||||
DISPLAYOUT(" the 'greedy', 'lazy', and 'lazy2' strategies.\n");
|
||||
|
||||
DISPLAYOUT("\n");
|
||||
DISPLAYOUT(" --format=zstd Compress files to the `.zst` format. [Default]\n");
|
||||
#ifdef ZSTD_GZCOMPRESS
|
||||
DISPLAYOUT(" --format=gzip compress files to the .gz format\n");
|
||||
DISPLAYOUT(" --format=gzip Compress files to the `.gz` format.\n");
|
||||
#endif
|
||||
#ifdef ZSTD_LZMACOMPRESS
|
||||
DISPLAYOUT(" --format=xz compress files to the .xz format\n");
|
||||
DISPLAYOUT(" --format=lzma compress files to the .lzma format\n");
|
||||
DISPLAYOUT(" --format=xz Compress files to the `.xz` format.\n");
|
||||
DISPLAYOUT(" --format=lzma Compress files to the `.lzma` format.\n");
|
||||
#endif
|
||||
#ifdef ZSTD_LZ4COMPRESS
|
||||
DISPLAYOUT( " --format=lz4 compress files to the .lz4 format\n");
|
||||
DISPLAYOUT( " --format=lz4 Compress files to the `.lz4` format.\n");
|
||||
#endif
|
||||
#endif /* !ZSTD_NOCOMPRESS */
|
||||
|
||||
#ifndef ZSTD_NODECOMPRESS
|
||||
DISPLAYOUT("\n");
|
||||
DISPLAYOUT("Advanced decompression options :\n");
|
||||
DISPLAYOUT(" -l print information about zstd compressed files\n");
|
||||
DISPLAYOUT(" --test test compressed file integrity\n");
|
||||
DISPLAYOUT(" -M# Set a memory usage limit for decompression\n");
|
||||
DISPLAYOUT("Advanced decompression options:\n");
|
||||
DISPLAYOUT(" -l Print information about Zstandard-compressed files.\n");
|
||||
DISPLAYOUT(" --test Test compressed file integrity.\n");
|
||||
DISPLAYOUT(" -M# Set the memory usage limit to # megabytes.\n");
|
||||
# if ZSTD_SPARSE_DEFAULT
|
||||
DISPLAYOUT(" --[no-]sparse sparse mode (default: enabled on file, disabled on stdout)\n");
|
||||
DISPLAYOUT(" --[no-]sparse Enable sparse mode. [Default: Enabled for files, disabled for STDOUT.]\n");
|
||||
# else
|
||||
DISPLAYOUT(" --[no-]sparse sparse mode (default: disabled)\n");
|
||||
DISPLAYOUT(" --[no-]sparse Enable sparse mode. [Default: Disabled]\n");
|
||||
# endif
|
||||
{
|
||||
char const* passThroughDefault = "disabled";
|
||||
char const* passThroughDefault = "Disabled";
|
||||
if (exeNameMatch(programName, ZSTD_CAT) ||
|
||||
exeNameMatch(programName, ZSTD_ZCAT) ||
|
||||
exeNameMatch(programName, ZSTD_GZCAT)) {
|
||||
passThroughDefault = "enabled";
|
||||
passThroughDefault = "Enabled";
|
||||
}
|
||||
DISPLAYOUT(" --[no-]pass-through : passes through uncompressed files as-is (default: %s)\n", passThroughDefault);
|
||||
DISPLAYOUT(" --[no-]pass-through Pass through uncompressed files as-is. [Default: %s]\n", passThroughDefault);
|
||||
}
|
||||
#endif /* ZSTD_NODECOMPRESS */
|
||||
|
||||
#ifndef ZSTD_NODICT
|
||||
DISPLAYOUT("\n");
|
||||
DISPLAYOUT("Dictionary builder :\n");
|
||||
DISPLAYOUT(" --train ## create a dictionary from a training set of files\n");
|
||||
DISPLAYOUT(" --train-cover[=k=#,d=#,steps=#,split=#,shrink[=#]] : use the cover algorithm with optional args\n");
|
||||
DISPLAYOUT(" --train-fastcover[=k=#,d=#,f=#,steps=#,split=#,accel=#,shrink[=#]] : use the fast cover algorithm with optional args\n");
|
||||
DISPLAYOUT(" --train-legacy[=s=#] : use the legacy algorithm with selectivity (default: %u)\n", g_defaultSelectivityLevel);
|
||||
DISPLAYOUT(" -o DICT DICT is dictionary name (default: %s)\n", g_defaultDictName);
|
||||
DISPLAYOUT(" --maxdict=# limit dictionary to specified size (default: %u)\n", g_defaultMaxDictSize);
|
||||
DISPLAYOUT(" --dictID=# force dictionary ID to specified value (default: random)\n");
|
||||
DISPLAYOUT("Dictionary builder:\n");
|
||||
DISPLAYOUT(" --train Create a dictionary from a training set of files.\n\n");
|
||||
DISPLAYOUT(" --train-cover[=k=#,d=#,steps=#,split=#,shrink[=#]]\n");
|
||||
DISPLAYOUT(" Use the cover algorithm (with optional arguments).\n");
|
||||
DISPLAYOUT(" --train-fastcover[=k=#,d=#,f=#,steps=#,split=#,accel=#,shrink[=#]]\n");
|
||||
DISPLAYOUT(" Use the fast cover algorithm (with optional arguments).\n\n");
|
||||
DISPLAYOUT(" --train-legacy[=s=#] Use the legacy algorithm with selectivity #. [Default: %u]\n", g_defaultSelectivityLevel);
|
||||
DISPLAYOUT(" -o NAME Use NAME as dictionary name. [Default: %s]\n", g_defaultDictName);
|
||||
DISPLAYOUT(" --maxdict=# Limit dictionary to specified size #. [Default: %u]\n", g_defaultMaxDictSize);
|
||||
DISPLAYOUT(" --dictID=# Force dictionary ID to #. [Default: Random]\n");
|
||||
#endif
|
||||
|
||||
#ifndef ZSTD_NOBENCH
|
||||
DISPLAYOUT("\n");
|
||||
DISPLAYOUT("Benchmark options : \n");
|
||||
DISPLAYOUT(" -b# benchmark file(s), using # compression level (default: %d)\n", ZSTDCLI_CLEVEL_DEFAULT);
|
||||
DISPLAYOUT(" -e# test all compression levels successively from -b# to -e# (default: 1)\n");
|
||||
DISPLAYOUT(" -i# minimum evaluation time in seconds (default: 3s)\n");
|
||||
DISPLAYOUT(" -B# cut file into independent chunks of size # (default: no chunking)\n");
|
||||
DISPLAYOUT(" -S output one benchmark result per input file (default: consolidated result)\n");
|
||||
DISPLAYOUT(" --priority=rt set process priority to real-time\n");
|
||||
DISPLAYOUT("Benchmark options:\n");
|
||||
DISPLAYOUT(" -b# Perform benchmarking with compression level #. [Default: %d]\n", ZSTDCLI_CLEVEL_DEFAULT);
|
||||
DISPLAYOUT(" -e# Test all compression levels up to #; starting level is `-b#`. [Default: 1]\n");
|
||||
DISPLAYOUT(" -i# Set the minimum evaluation to time # seconds. [Default: 3]\n");
|
||||
DISPLAYOUT(" -B# Cut file into independent chunks of size #. [Default: No chunking]\n");
|
||||
DISPLAYOUT(" -S Output one benchmark result per input file. [Default: Consolidated result]\n");
|
||||
DISPLAYOUT(" --priority=rt Set process priority to real-time.\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -325,7 +339,7 @@ static const char* lastNameFromPath(const char* path)
|
||||
|
||||
static void errorOut(const char* msg)
|
||||
{
|
||||
DISPLAY("%s \n", msg); exit(1);
|
||||
DISPLAYLEVEL(1, "%s \n", msg); exit(1);
|
||||
}
|
||||
|
||||
/*! readU32FromCharChecked() :
|
||||
@ -772,13 +786,13 @@ static unsigned init_nbThreads(void) {
|
||||
} else { \
|
||||
argNb++; \
|
||||
if (argNb >= argCount) { \
|
||||
DISPLAY("error: missing command argument \n"); \
|
||||
DISPLAYLEVEL(1, "error: missing command argument \n"); \
|
||||
CLEAN_RETURN(1); \
|
||||
} \
|
||||
ptr = argv[argNb]; \
|
||||
assert(ptr != NULL); \
|
||||
if (ptr[0]=='-') { \
|
||||
DISPLAY("error: command cannot be separated from its argument by another command \n"); \
|
||||
DISPLAYLEVEL(1, "error: command cannot be separated from its argument by another command \n"); \
|
||||
CLEAN_RETURN(1); \
|
||||
} } }
|
||||
|
||||
@ -824,7 +838,6 @@ int main(int argCount, const char* argv[])
|
||||
ldmFlag = 0,
|
||||
main_pause = 0,
|
||||
adapt = 0,
|
||||
useRowMatchFinder = 0,
|
||||
adaptMin = MINCLEVEL,
|
||||
adaptMax = MAXCLEVEL,
|
||||
rsyncable = 0,
|
||||
@ -836,7 +849,10 @@ int main(int argCount, const char* argv[])
|
||||
defaultLogicalCores = 0,
|
||||
showDefaultCParams = 0,
|
||||
ultra=0,
|
||||
contentSize=1;
|
||||
contentSize=1,
|
||||
removeSrcFile=0;
|
||||
ZSTD_paramSwitch_e useRowMatchFinder = ZSTD_ps_auto;
|
||||
FIO_compressionType_t cType = FIO_zstdCompression;
|
||||
unsigned nbWorkers = 0;
|
||||
double compressibility = 0.5;
|
||||
unsigned bench_nbSeconds = 3; /* would be better if this value was synchronized from bench */
|
||||
@ -844,6 +860,7 @@ int main(int argCount, const char* argv[])
|
||||
|
||||
FIO_prefs_t* const prefs = FIO_createPreferences();
|
||||
FIO_ctx_t* const fCtx = FIO_createContext();
|
||||
FIO_progressSetting_e progress = FIO_ps_auto;
|
||||
zstd_operation_mode operation = zom_compress;
|
||||
ZSTD_compressionParameters compressionParams;
|
||||
int cLevel = init_cLevel();
|
||||
@ -883,7 +900,7 @@ int main(int argCount, const char* argv[])
|
||||
(void)recursive; (void)cLevelLast; /* not used when ZSTD_NOBENCH set */
|
||||
(void)memLimit;
|
||||
assert(argCount >= 1);
|
||||
if ((filenames==NULL) || (file_of_names==NULL)) { DISPLAY("zstd: allocation error \n"); exit(1); }
|
||||
if ((filenames==NULL) || (file_of_names==NULL)) { DISPLAYLEVEL(1, "zstd: allocation error \n"); exit(1); }
|
||||
programName = lastNameFromPath(programName);
|
||||
#ifdef ZSTD_MULTITHREAD
|
||||
nbWorkers = init_nbThreads();
|
||||
@ -895,17 +912,17 @@ int main(int argCount, const char* argv[])
|
||||
if (exeNameMatch(programName, ZSTD_CAT)) { operation=zom_decompress; FIO_overwriteMode(prefs); forceStdout=1; followLinks=1; FIO_setPassThroughFlag(prefs, 1); outFileName=stdoutmark; g_displayLevel=1; } /* supports multiple formats */
|
||||
if (exeNameMatch(programName, ZSTD_ZCAT)) { operation=zom_decompress; FIO_overwriteMode(prefs); forceStdout=1; followLinks=1; FIO_setPassThroughFlag(prefs, 1); outFileName=stdoutmark; g_displayLevel=1; } /* behave like zcat, also supports multiple formats */
|
||||
if (exeNameMatch(programName, ZSTD_GZ)) { /* behave like gzip */
|
||||
suffix = GZ_EXTENSION; FIO_setCompressionType(prefs, FIO_gzipCompression); FIO_setRemoveSrcFile(prefs, 1);
|
||||
suffix = GZ_EXTENSION; cType = FIO_gzipCompression; removeSrcFile=1;
|
||||
dictCLevel = cLevel = 6; /* gzip default is -6 */
|
||||
}
|
||||
if (exeNameMatch(programName, ZSTD_GUNZIP)) { operation=zom_decompress; FIO_setRemoveSrcFile(prefs, 1); } /* behave like gunzip, also supports multiple formats */
|
||||
if (exeNameMatch(programName, ZSTD_GUNZIP)) { operation=zom_decompress; removeSrcFile=1; } /* behave like gunzip, also supports multiple formats */
|
||||
if (exeNameMatch(programName, ZSTD_GZCAT)) { operation=zom_decompress; FIO_overwriteMode(prefs); forceStdout=1; followLinks=1; FIO_setPassThroughFlag(prefs, 1); outFileName=stdoutmark; g_displayLevel=1; } /* behave like gzcat, also supports multiple formats */
|
||||
if (exeNameMatch(programName, ZSTD_LZMA)) { suffix = LZMA_EXTENSION; FIO_setCompressionType(prefs, FIO_lzmaCompression); FIO_setRemoveSrcFile(prefs, 1); } /* behave like lzma */
|
||||
if (exeNameMatch(programName, ZSTD_UNLZMA)) { operation=zom_decompress; FIO_setCompressionType(prefs, FIO_lzmaCompression); FIO_setRemoveSrcFile(prefs, 1); } /* behave like unlzma, also supports multiple formats */
|
||||
if (exeNameMatch(programName, ZSTD_XZ)) { suffix = XZ_EXTENSION; FIO_setCompressionType(prefs, FIO_xzCompression); FIO_setRemoveSrcFile(prefs, 1); } /* behave like xz */
|
||||
if (exeNameMatch(programName, ZSTD_UNXZ)) { operation=zom_decompress; FIO_setCompressionType(prefs, FIO_xzCompression); FIO_setRemoveSrcFile(prefs, 1); } /* behave like unxz, also supports multiple formats */
|
||||
if (exeNameMatch(programName, ZSTD_LZ4)) { suffix = LZ4_EXTENSION; FIO_setCompressionType(prefs, FIO_lz4Compression); } /* behave like lz4 */
|
||||
if (exeNameMatch(programName, ZSTD_UNLZ4)) { operation=zom_decompress; FIO_setCompressionType(prefs, FIO_lz4Compression); } /* behave like unlz4, also supports multiple formats */
|
||||
if (exeNameMatch(programName, ZSTD_LZMA)) { suffix = LZMA_EXTENSION; cType = FIO_lzmaCompression; removeSrcFile=1; } /* behave like lzma */
|
||||
if (exeNameMatch(programName, ZSTD_UNLZMA)) { operation=zom_decompress; cType = FIO_lzmaCompression; removeSrcFile=1; } /* behave like unlzma, also supports multiple formats */
|
||||
if (exeNameMatch(programName, ZSTD_XZ)) { suffix = XZ_EXTENSION; cType = FIO_xzCompression; removeSrcFile=1; } /* behave like xz */
|
||||
if (exeNameMatch(programName, ZSTD_UNXZ)) { operation=zom_decompress; cType = FIO_xzCompression; removeSrcFile=1; } /* behave like unxz, also supports multiple formats */
|
||||
if (exeNameMatch(programName, ZSTD_LZ4)) { suffix = LZ4_EXTENSION; cType = FIO_lz4Compression; } /* behave like lz4 */
|
||||
if (exeNameMatch(programName, ZSTD_UNLZ4)) { operation=zom_decompress; cType = FIO_lz4Compression; } /* behave like unlz4, also supports multiple formats */
|
||||
memset(&compressionParams, 0, sizeof(compressionParams));
|
||||
|
||||
/* init crash handler */
|
||||
@ -942,7 +959,7 @@ int main(int argCount, const char* argv[])
|
||||
if (!strcmp(argument, "--help")) { usage_advanced(programName); CLEAN_RETURN(0); }
|
||||
if (!strcmp(argument, "--verbose")) { g_displayLevel++; continue; }
|
||||
if (!strcmp(argument, "--quiet")) { g_displayLevel--; continue; }
|
||||
if (!strcmp(argument, "--stdout")) { forceStdout=1; outFileName=stdoutmark; FIO_setRemoveSrcFile(prefs, 0); g_displayLevel-=(g_displayLevel==2); continue; }
|
||||
if (!strcmp(argument, "--stdout")) { forceStdout=1; outFileName=stdoutmark; removeSrcFile=0; continue; }
|
||||
if (!strcmp(argument, "--ultra")) { ultra=1; continue; }
|
||||
if (!strcmp(argument, "--check")) { FIO_setChecksumFlag(prefs, 2); continue; }
|
||||
if (!strcmp(argument, "--no-check")) { FIO_setChecksumFlag(prefs, 0); continue; }
|
||||
@ -955,38 +972,42 @@ int main(int argCount, const char* argv[])
|
||||
if (!strcmp(argument, "--no-asyncio")) { FIO_setAsyncIOFlag(prefs, 0); continue;}
|
||||
if (!strcmp(argument, "--train")) { operation=zom_train; if (outFileName==NULL) outFileName=g_defaultDictName; continue; }
|
||||
if (!strcmp(argument, "--no-dictID")) { FIO_setDictIDFlag(prefs, 0); continue; }
|
||||
if (!strcmp(argument, "--keep")) { FIO_setRemoveSrcFile(prefs, 0); continue; }
|
||||
if (!strcmp(argument, "--rm")) { FIO_setRemoveSrcFile(prefs, 1); continue; }
|
||||
if (!strcmp(argument, "--keep")) { removeSrcFile=0; continue; }
|
||||
if (!strcmp(argument, "--rm")) { removeSrcFile=1; continue; }
|
||||
if (!strcmp(argument, "--priority=rt")) { setRealTimePrio = 1; continue; }
|
||||
if (!strcmp(argument, "--show-default-cparams")) { showDefaultCParams = 1; continue; }
|
||||
if (!strcmp(argument, "--content-size")) { contentSize = 1; continue; }
|
||||
if (!strcmp(argument, "--no-content-size")) { contentSize = 0; continue; }
|
||||
if (!strcmp(argument, "--adapt")) { adapt = 1; continue; }
|
||||
if (!strcmp(argument, "--no-row-match-finder")) { useRowMatchFinder = 1; continue; }
|
||||
if (!strcmp(argument, "--row-match-finder")) { useRowMatchFinder = 2; continue; }
|
||||
if (!strcmp(argument, "--no-row-match-finder")) { useRowMatchFinder = ZSTD_ps_disable; continue; }
|
||||
if (!strcmp(argument, "--row-match-finder")) { useRowMatchFinder = ZSTD_ps_enable; continue; }
|
||||
if (longCommandWArg(&argument, "--adapt=")) { adapt = 1; if (!parseAdaptParameters(argument, &adaptMin, &adaptMax)) { badusage(programName); CLEAN_RETURN(1); } continue; }
|
||||
if (!strcmp(argument, "--single-thread")) { nbWorkers = 0; singleThread = 1; continue; }
|
||||
if (!strcmp(argument, "--format=zstd")) { suffix = ZSTD_EXTENSION; FIO_setCompressionType(prefs, FIO_zstdCompression); continue; }
|
||||
if (!strcmp(argument, "--format=zstd")) { suffix = ZSTD_EXTENSION; cType = FIO_zstdCompression; continue; }
|
||||
#ifdef ZSTD_GZCOMPRESS
|
||||
if (!strcmp(argument, "--format=gzip")) { suffix = GZ_EXTENSION; FIO_setCompressionType(prefs, FIO_gzipCompression); continue; }
|
||||
if (!strcmp(argument, "--format=gzip")) { suffix = GZ_EXTENSION; cType = FIO_gzipCompression; continue; }
|
||||
if (exeNameMatch(programName, ZSTD_GZ)) { /* behave like gzip */
|
||||
if (!strcmp(argument, "--best")) { dictCLevel = cLevel = 9; continue; }
|
||||
if (!strcmp(argument, "--no-name")) { /* ignore for now */; continue; }
|
||||
}
|
||||
#endif
|
||||
#ifdef ZSTD_LZMACOMPRESS
|
||||
if (!strcmp(argument, "--format=lzma")) { suffix = LZMA_EXTENSION; FIO_setCompressionType(prefs, FIO_lzmaCompression); continue; }
|
||||
if (!strcmp(argument, "--format=xz")) { suffix = XZ_EXTENSION; FIO_setCompressionType(prefs, FIO_xzCompression); continue; }
|
||||
if (!strcmp(argument, "--format=lzma")) { suffix = LZMA_EXTENSION; cType = FIO_lzmaCompression; continue; }
|
||||
if (!strcmp(argument, "--format=xz")) { suffix = XZ_EXTENSION; cType = FIO_xzCompression; continue; }
|
||||
#endif
|
||||
#ifdef ZSTD_LZ4COMPRESS
|
||||
if (!strcmp(argument, "--format=lz4")) { suffix = LZ4_EXTENSION; FIO_setCompressionType(prefs, FIO_lz4Compression); continue; }
|
||||
if (!strcmp(argument, "--format=lz4")) { suffix = LZ4_EXTENSION; cType = FIO_lz4Compression; continue; }
|
||||
#endif
|
||||
if (!strcmp(argument, "--rsyncable")) { rsyncable = 1; continue; }
|
||||
if (!strcmp(argument, "--compress-literals")) { literalCompressionMode = ZSTD_ps_enable; continue; }
|
||||
if (!strcmp(argument, "--no-compress-literals")) { literalCompressionMode = ZSTD_ps_disable; continue; }
|
||||
if (!strcmp(argument, "--no-progress")) { FIO_setProgressSetting(FIO_ps_never); continue; }
|
||||
if (!strcmp(argument, "--progress")) { FIO_setProgressSetting(FIO_ps_always); continue; }
|
||||
if (!strcmp(argument, "--no-progress")) { progress = FIO_ps_never; continue; }
|
||||
if (!strcmp(argument, "--progress")) { progress = FIO_ps_always; continue; }
|
||||
if (!strcmp(argument, "--exclude-compressed")) { FIO_setExcludeCompressedFile(prefs, 1); continue; }
|
||||
if (!strcmp(argument, "--fake-stdin-is-console")) { UTIL_fakeStdinIsConsole(); continue; }
|
||||
if (!strcmp(argument, "--fake-stdout-is-console")) { UTIL_fakeStdoutIsConsole(); continue; }
|
||||
if (!strcmp(argument, "--fake-stderr-is-console")) { UTIL_fakeStderrIsConsole(); continue; }
|
||||
if (!strcmp(argument, "--trace-file-stat")) { UTIL_traceFileStat(); continue; }
|
||||
|
||||
/* long commands with arguments */
|
||||
#ifndef ZSTD_NODICT
|
||||
@ -1031,14 +1052,14 @@ int main(int argCount, const char* argv[])
|
||||
if (longCommandWArg(&argument, "--block-size")) { NEXT_TSIZE(blockSize); continue; }
|
||||
if (longCommandWArg(&argument, "--maxdict")) { NEXT_UINT32(maxDictSize); continue; }
|
||||
if (longCommandWArg(&argument, "--dictID")) { NEXT_UINT32(dictID); continue; }
|
||||
if (longCommandWArg(&argument, "--zstd=")) { if (!parseCompressionParameters(argument, &compressionParams)) { badusage(programName); CLEAN_RETURN(1); } continue; }
|
||||
if (longCommandWArg(&argument, "--zstd=")) { if (!parseCompressionParameters(argument, &compressionParams)) { badusage(programName); CLEAN_RETURN(1); } ; cType = FIO_zstdCompression; continue; }
|
||||
if (longCommandWArg(&argument, "--stream-size")) { NEXT_TSIZE(streamSrcSize); continue; }
|
||||
if (longCommandWArg(&argument, "--target-compressed-block-size")) { NEXT_TSIZE(targetCBlockSize); continue; }
|
||||
if (longCommandWArg(&argument, "--size-hint")) { NEXT_TSIZE(srcSizeHint); continue; }
|
||||
if (longCommandWArg(&argument, "--output-dir-flat")) {
|
||||
NEXT_FIELD(outDirName);
|
||||
if (strlen(outDirName) == 0) {
|
||||
DISPLAY("error: output dir cannot be empty string (did you mean to pass '.' instead?)\n");
|
||||
DISPLAYLEVEL(1, "error: output dir cannot be empty string (did you mean to pass '.' instead?)\n");
|
||||
CLEAN_RETURN(1);
|
||||
}
|
||||
continue;
|
||||
@ -1054,7 +1075,7 @@ int main(int argCount, const char* argv[])
|
||||
if (longCommandWArg(&argument, "--output-dir-mirror")) {
|
||||
NEXT_FIELD(outMirroredDirName);
|
||||
if (strlen(outMirroredDirName) == 0) {
|
||||
DISPLAY("error: output dir cannot be empty string (did you mean to pass '.' instead?)\n");
|
||||
DISPLAYLEVEL(1, "error: output dir cannot be empty string (did you mean to pass '.' instead?)\n");
|
||||
CLEAN_RETURN(1);
|
||||
}
|
||||
continue;
|
||||
@ -1149,7 +1170,7 @@ int main(int argCount, const char* argv[])
|
||||
operation=zom_decompress; argument++; break;
|
||||
|
||||
/* Force stdout, even if stdout==console */
|
||||
case 'c': forceStdout=1; outFileName=stdoutmark; FIO_setRemoveSrcFile(prefs, 0); argument++; break;
|
||||
case 'c': forceStdout=1; outFileName=stdoutmark; removeSrcFile=0; argument++; break;
|
||||
|
||||
/* do not store filename - gzip compatibility - nothing to do */
|
||||
case 'n': argument++; break;
|
||||
@ -1167,7 +1188,7 @@ int main(int argCount, const char* argv[])
|
||||
case 'q': g_displayLevel--; argument++; break;
|
||||
|
||||
/* keep source file (default) */
|
||||
case 'k': FIO_setRemoveSrcFile(prefs, 0); argument++; break;
|
||||
case 'k': removeSrcFile=0; argument++; break;
|
||||
|
||||
/* Checksum */
|
||||
case 'C': FIO_setChecksumFlag(prefs, 2); argument++; break;
|
||||
@ -1330,7 +1351,7 @@ int main(int argCount, const char* argv[])
|
||||
int const ret = FIO_listMultipleFiles((unsigned)filenames->tableSize, filenames->fileNames, g_displayLevel);
|
||||
CLEAN_RETURN(ret);
|
||||
#else
|
||||
DISPLAY("file information is not supported \n");
|
||||
DISPLAYLEVEL(1, "file information is not supported \n");
|
||||
CLEAN_RETURN(1);
|
||||
#endif
|
||||
}
|
||||
@ -1338,6 +1359,10 @@ int main(int argCount, const char* argv[])
|
||||
/* Check if benchmark is selected */
|
||||
if (operation==zom_bench) {
|
||||
#ifndef ZSTD_NOBENCH
|
||||
if (cType != FIO_zstdCompression) {
|
||||
DISPLAYLEVEL(1, "benchmark mode is only compatible with zstd format \n");
|
||||
CLEAN_RETURN(1);
|
||||
}
|
||||
benchParams.blockSize = blockSize;
|
||||
benchParams.nbWorkers = (int)nbWorkers;
|
||||
benchParams.realTime = (unsigned)setRealTimePrio;
|
||||
@ -1345,7 +1370,7 @@ int main(int argCount, const char* argv[])
|
||||
benchParams.ldmFlag = ldmFlag;
|
||||
benchParams.ldmMinMatch = (int)g_ldmMinMatch;
|
||||
benchParams.ldmHashLog = (int)g_ldmHashLog;
|
||||
benchParams.useRowMatchFinder = useRowMatchFinder;
|
||||
benchParams.useRowMatchFinder = (int)useRowMatchFinder;
|
||||
if (g_ldmBucketSizeLog != LDM_PARAM_DEFAULT) {
|
||||
benchParams.ldmBucketSizeLog = (int)g_ldmBucketSizeLog;
|
||||
}
|
||||
@ -1366,15 +1391,18 @@ int main(int argCount, const char* argv[])
|
||||
int c;
|
||||
DISPLAYLEVEL(3, "Benchmarking %s \n", filenames->fileNames[i]);
|
||||
for(c = cLevel; c <= cLevelLast; c++) {
|
||||
BMK_benchFilesAdvanced(&filenames->fileNames[i], 1, dictFileName, c, &compressionParams, g_displayLevel, &benchParams);
|
||||
BMK_benchOutcome_t const bo = BMK_benchFilesAdvanced(&filenames->fileNames[i], 1, dictFileName, c, &compressionParams, g_displayLevel, &benchParams);
|
||||
if (!BMK_isSuccessful_benchOutcome(bo)) return 1;
|
||||
} }
|
||||
} else {
|
||||
for(; cLevel <= cLevelLast; cLevel++) {
|
||||
BMK_benchFilesAdvanced(filenames->fileNames, (unsigned)filenames->tableSize, dictFileName, cLevel, &compressionParams, g_displayLevel, &benchParams);
|
||||
BMK_benchOutcome_t const bo = BMK_benchFilesAdvanced(filenames->fileNames, (unsigned)filenames->tableSize, dictFileName, cLevel, &compressionParams, g_displayLevel, &benchParams);
|
||||
if (!BMK_isSuccessful_benchOutcome(bo)) return 1;
|
||||
} }
|
||||
} else {
|
||||
for(; cLevel <= cLevelLast; cLevel++) {
|
||||
BMK_syntheticTest(cLevel, compressibility, &compressionParams, g_displayLevel, &benchParams);
|
||||
BMK_benchOutcome_t const bo = BMK_syntheticTest(cLevel, compressibility, &compressionParams, g_displayLevel, &benchParams);
|
||||
if (!BMK_isSuccessful_benchOutcome(bo)) return 1;
|
||||
} }
|
||||
|
||||
#else
|
||||
@ -1416,7 +1444,7 @@ int main(int argCount, const char* argv[])
|
||||
}
|
||||
|
||||
#ifndef ZSTD_NODECOMPRESS
|
||||
if (operation==zom_test) { FIO_setTestMode(prefs, 1); outFileName=nulmark; FIO_setRemoveSrcFile(prefs, 0); } /* test mode */
|
||||
if (operation==zom_test) { FIO_setTestMode(prefs, 1); outFileName=nulmark; removeSrcFile=0; } /* test mode */
|
||||
#endif
|
||||
|
||||
/* No input filename ==> use stdin and stdout */
|
||||
@ -1437,12 +1465,12 @@ int main(int argCount, const char* argv[])
|
||||
/* Check if input/output defined as console; trigger an error in this case */
|
||||
if (!forceStdin
|
||||
&& (UTIL_searchFileNamesTable(filenames, stdinmark) != -1)
|
||||
&& IS_CONSOLE(stdin) ) {
|
||||
&& UTIL_isConsole(stdin) ) {
|
||||
DISPLAYLEVEL(1, "stdin is a console, aborting\n");
|
||||
CLEAN_RETURN(1);
|
||||
}
|
||||
if ( (!outFileName || !strcmp(outFileName, stdoutmark))
|
||||
&& IS_CONSOLE(stdout)
|
||||
&& UTIL_isConsole(stdout)
|
||||
&& (UTIL_searchFileNamesTable(filenames, stdinmark) != -1)
|
||||
&& !forceStdout
|
||||
&& operation!=zom_decompress ) {
|
||||
@ -1461,25 +1489,35 @@ int main(int argCount, const char* argv[])
|
||||
|
||||
if (showDefaultCParams) {
|
||||
if (operation == zom_decompress) {
|
||||
DISPLAY("error : can't use --show-default-cparams in decompression mode \n");
|
||||
DISPLAYLEVEL(1, "error : can't use --show-default-cparams in decompression mode \n");
|
||||
CLEAN_RETURN(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (dictFileName != NULL && patchFromDictFileName != NULL) {
|
||||
DISPLAY("error : can't use -D and --patch-from=# at the same time \n");
|
||||
DISPLAYLEVEL(1, "error : can't use -D and --patch-from=# at the same time \n");
|
||||
CLEAN_RETURN(1);
|
||||
}
|
||||
|
||||
if (patchFromDictFileName != NULL && filenames->tableSize > 1) {
|
||||
DISPLAY("error : can't use --patch-from=# on multiple files \n");
|
||||
DISPLAYLEVEL(1, "error : can't use --patch-from=# on multiple files \n");
|
||||
CLEAN_RETURN(1);
|
||||
}
|
||||
|
||||
/* No status message in pipe mode (stdin - stdout) */
|
||||
/* No status message by default when output is stdout */
|
||||
hasStdout = outFileName && !strcmp(outFileName,stdoutmark);
|
||||
if (hasStdout && (g_displayLevel==2)) g_displayLevel=1;
|
||||
|
||||
if ((hasStdout || !IS_CONSOLE(stderr)) && (g_displayLevel==2)) g_displayLevel=1;
|
||||
/* when stderr is not the console, do not pollute it with progress updates (unless requested) */
|
||||
if (!UTIL_isConsole(stderr) && (progress!=FIO_ps_always)) progress=FIO_ps_never;
|
||||
FIO_setProgressSetting(progress);
|
||||
|
||||
/* don't remove source files when output is stdout */;
|
||||
if (hasStdout && removeSrcFile) {
|
||||
DISPLAYLEVEL(3, "Note: src files are not removed when output is stdout \n");
|
||||
removeSrcFile = 0;
|
||||
}
|
||||
FIO_setRemoveSrcFile(prefs, removeSrcFile);
|
||||
|
||||
/* IO Stream/File */
|
||||
FIO_setHasStdoutOutput(fCtx, hasStdout);
|
||||
@ -1499,6 +1537,7 @@ int main(int argCount, const char* argv[])
|
||||
FIO_setMemLimit(prefs, memLimit);
|
||||
if (operation==zom_compress) {
|
||||
#ifndef ZSTD_NOCOMPRESS
|
||||
FIO_setCompressionType(prefs, cType);
|
||||
FIO_setContentSize(prefs, contentSize);
|
||||
FIO_setNbWorkers(prefs, (int)nbWorkers);
|
||||
FIO_setBlockSize(prefs, (int)blockSize);
|
||||
@ -1509,7 +1548,7 @@ int main(int argCount, const char* argv[])
|
||||
if (g_ldmBucketSizeLog != LDM_PARAM_DEFAULT) FIO_setLdmBucketSizeLog(prefs, (int)g_ldmBucketSizeLog);
|
||||
if (g_ldmHashRateLog != LDM_PARAM_DEFAULT) FIO_setLdmHashRateLog(prefs, (int)g_ldmHashRateLog);
|
||||
FIO_setAdaptiveMode(prefs, adapt);
|
||||
FIO_setUseRowMatchFinder(prefs, useRowMatchFinder);
|
||||
FIO_setUseRowMatchFinder(prefs, (int)useRowMatchFinder);
|
||||
FIO_setAdaptMin(prefs, adaptMin);
|
||||
FIO_setAdaptMax(prefs, adaptMax);
|
||||
FIO_setRsyncable(prefs, rsyncable);
|
||||
@ -1543,8 +1582,12 @@ int main(int argCount, const char* argv[])
|
||||
else
|
||||
operationResult = FIO_compressMultipleFilenames(fCtx, prefs, filenames->fileNames, outMirroredDirName, outDirName, outFileName, suffix, dictFileName, cLevel, compressionParams);
|
||||
#else
|
||||
(void)contentSize; (void)suffix; (void)adapt; (void)rsyncable; (void)ultra; (void)cLevel; (void)ldmFlag; (void)literalCompressionMode; (void)targetCBlockSize; (void)streamSrcSize; (void)srcSizeHint; (void)ZSTD_strategyMap; (void)useRowMatchFinder; /* not used when ZSTD_NOCOMPRESS set */
|
||||
DISPLAY("Compression not supported \n");
|
||||
/* these variables are only used when compression mode is enabled */
|
||||
(void)contentSize; (void)suffix; (void)adapt; (void)rsyncable;
|
||||
(void)ultra; (void)cLevel; (void)ldmFlag; (void)literalCompressionMode;
|
||||
(void)targetCBlockSize; (void)streamSrcSize; (void)srcSizeHint;
|
||||
(void)ZSTD_strategyMap; (void)useRowMatchFinder; (void)cType;
|
||||
DISPLAYLEVEL(1, "Compression not supported \n");
|
||||
#endif
|
||||
} else { /* decompression or test */
|
||||
#ifndef ZSTD_NODECOMPRESS
|
||||
@ -1554,7 +1597,7 @@ int main(int argCount, const char* argv[])
|
||||
operationResult = FIO_decompressMultipleFilenames(fCtx, prefs, filenames->fileNames, outMirroredDirName, outDirName, outFileName, dictFileName);
|
||||
}
|
||||
#else
|
||||
DISPLAY("Decompression not supported \n");
|
||||
DISPLAYLEVEL(1, "Decompression not supported \n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user