1 /* 2 * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. 3 * All rights reserved. 4 * 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). 8 * You may select, at your option, one of the above-listed licenses. 9 */ 10 11 12 #ifndef FILEIO_H_23981798732 13 #define FILEIO_H_23981798732 14 15 #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_compressionParameters */ 16 #include "zstd.h" /* ZSTD_* */ 17 18 #if defined (__cplusplus) 19 extern "C" { 20 #endif 21 22 23 /* ************************************* 24 * Special i/o constants 25 **************************************/ 26 #define stdinmark "/*stdin*\\" 27 #define stdoutmark "/*stdout*\\" 28 #ifdef _WIN32 29 # define nulmark "nul" 30 #else 31 # define nulmark "/dev/null" 32 #endif 33 #define LZMA_EXTENSION ".lzma" 34 #define XZ_EXTENSION ".xz" 35 #define GZ_EXTENSION ".gz" 36 #define ZSTD_EXTENSION ".zst" 37 #define LZ4_EXTENSION ".lz4" 38 39 40 /*-************************************* 41 * Types 42 ***************************************/ 43 typedef enum { FIO_zstdCompression, FIO_gzipCompression, FIO_xzCompression, FIO_lzmaCompression, FIO_lz4Compression } FIO_compressionType_t; 44 45 46 /*-************************************* 47 * Parameters 48 ***************************************/ 49 void FIO_setCompressionType(FIO_compressionType_t compressionType); 50 void FIO_overwriteMode(void); 51 void FIO_setAdaptiveMode(unsigned adapt); 52 void FIO_setAdaptMin(int minCLevel); 53 void FIO_setAdaptMax(int maxCLevel); 54 void FIO_setBlockSize(unsigned blockSize); 55 void FIO_setChecksumFlag(unsigned checksumFlag); 56 void FIO_setDictIDFlag(unsigned dictIDFlag); 57 void FIO_setLdmBucketSizeLog(unsigned ldmBucketSizeLog); 58 void FIO_setLdmFlag(unsigned ldmFlag); 59 void FIO_setLdmHashRateLog(unsigned ldmHashRateLog); 60 void FIO_setLdmHashLog(unsigned ldmHashLog); 61 void FIO_setLdmMinMatch(unsigned ldmMinMatch); 62 void FIO_setMemLimit(unsigned memLimit); 63 void FIO_setNbWorkers(unsigned nbWorkers); 64 void FIO_setNotificationLevel(unsigned level); 65 void FIO_setOverlapLog(unsigned overlapLog); 66 void FIO_setRemoveSrcFile(unsigned flag); 67 void FIO_setSparseWrite(unsigned sparse); /**< 0: no sparse; 1: disable on stdout; 2: always enabled */ 68 void FIO_setRsyncable(unsigned rsyncable); 69 void FIO_setNoProgress(unsigned noProgress); 70 71 72 /*-************************************* 73 * Single File functions 74 ***************************************/ 75 /** FIO_compressFilename() : 76 @return : 0 == ok; 1 == pb with src file. */ 77 int FIO_compressFilename (const char* outfilename, const char* infilename, const char* dictFileName, 78 int compressionLevel, ZSTD_compressionParameters comprParams); 79 80 /** FIO_decompressFilename() : 81 @return : 0 == ok; 1 == pb with src file. */ 82 int FIO_decompressFilename (const char* outfilename, const char* infilename, const char* dictFileName); 83 84 int FIO_listMultipleFiles(unsigned numFiles, const char** filenameTable, int displayLevel); 85 86 87 /*-************************************* 88 * Multiple File functions 89 ***************************************/ 90 /** FIO_compressMultipleFilenames() : 91 @return : nb of missing files */ 92 int FIO_compressMultipleFilenames(const char** srcNamesTable, unsigned nbFiles, 93 const char* outFileName, const char* suffix, 94 const char* dictFileName, int compressionLevel, 95 ZSTD_compressionParameters comprParams); 96 97 /** FIO_decompressMultipleFilenames() : 98 @return : nb of missing or skipped files */ 99 int FIO_decompressMultipleFilenames(const char** srcNamesTable, unsigned nbFiles, 100 const char* outFileName, 101 const char* dictFileName); 102 103 104 /*-************************************* 105 * Advanced stuff (should actually be hosted elsewhere) 106 ***************************************/ 107 108 /* custom crash signal handler */ 109 void FIO_addAbortHandler(void); 110 111 112 113 #if defined (__cplusplus) 114 } 115 #endif 116 117 #endif /* FILEIO_H_23981798732 */ 118