2 * Copyright (c) 2016-present, Facebook, Inc.
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
13 #undef ZSTD_STATIC_LINKING_ONLY
22 enum class WriteMode { Regular, Auto, Sparse };
25 unsigned maxWindowLog;
26 unsigned compressionLevel;
28 std::vector<std::string> inputFiles;
29 std::string outputFile;
37 Success, // Successfully parsed options
38 Failure, // Failure to parse options
39 Message // Options specified to print a message (e.g. "-h")
43 Options(unsigned numThreads, unsigned maxWindowLog, unsigned compressionLevel,
44 bool decompress, std::vector<std::string> inputFiles,
45 std::string outputFile, bool overwrite, bool keepSource,
46 WriteMode writeMode, bool checksum, int verbosity)
47 : numThreads(numThreads), maxWindowLog(maxWindowLog),
48 compressionLevel(compressionLevel), decompress(decompress),
49 inputFiles(std::move(inputFiles)), outputFile(std::move(outputFile)),
50 overwrite(overwrite), keepSource(keepSource), writeMode(writeMode),
51 checksum(checksum), verbosity(verbosity) {}
53 Status parse(int argc, const char **argv);
55 ZSTD_parameters determineParameters() const {
56 ZSTD_parameters params = ZSTD_getParams(compressionLevel, 0, 0);
57 params.fParams.contentSizeFlag = 0;
58 params.fParams.checksumFlag = checksum;
59 if (maxWindowLog != 0 && params.cParams.windowLog > maxWindowLog) {
60 params.cParams.windowLog = maxWindowLog;
61 params.cParams = ZSTD_adjustCParams(params.cParams, 0, 0);
66 std::string getOutputFile(const std::string &inputFile) const;