2 * Copyright (c) Meta Platforms, Inc. and affiliates.
5 * This source code is licensed under both the BSD-style license (found in the
6 * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7 * in the COPYING file in the root directory of this source tree).
11 #define ZSTD_STATIC_LINKING_ONLY
12 #define ZSTD_DISABLE_DEPRECATE_WARNINGS /* No deprecation warnings, pzstd itself is deprecated
13 * and uses deprecated functions
16 #undef ZSTD_STATIC_LINKING_ONLY
25 enum class WriteMode { Regular, Auto, Sparse };
28 unsigned maxWindowLog;
29 unsigned compressionLevel;
31 std::vector<std::string> inputFiles;
32 std::string outputFile;
40 Success, // Successfully parsed options
41 Failure, // Failure to parse options
42 Message // Options specified to print a message (e.g. "-h")
46 Options(unsigned numThreads, unsigned maxWindowLog, unsigned compressionLevel,
47 bool decompress, std::vector<std::string> inputFiles,
48 std::string outputFile, bool overwrite, bool keepSource,
49 WriteMode writeMode, bool checksum, int verbosity)
50 : numThreads(numThreads), maxWindowLog(maxWindowLog),
51 compressionLevel(compressionLevel), decompress(decompress),
52 inputFiles(std::move(inputFiles)), outputFile(std::move(outputFile)),
53 overwrite(overwrite), keepSource(keepSource), writeMode(writeMode),
54 checksum(checksum), verbosity(verbosity) {}
56 Status parse(int argc, const char **argv);
58 ZSTD_parameters determineParameters() const {
59 ZSTD_parameters params = ZSTD_getParams(compressionLevel, 0, 0);
60 params.fParams.contentSizeFlag = 0;
61 params.fParams.checksumFlag = checksum;
62 if (maxWindowLog != 0 && params.cParams.windowLog > maxWindowLog) {
63 params.cParams.windowLog = maxWindowLog;
64 params.cParams = ZSTD_adjustCParams(params.cParams, 0, 0);
69 std::string getOutputFile(const std::string &inputFile) const;