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_setLdmHashEveryLog(unsigned ldmHashEveryLog); 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 69 70 /*-************************************* 71 * Single File functions 72 ***************************************/ 73 /** FIO_compressFilename() : 74 @return : 0 == ok; 1 == pb with src file. */ 75 int FIO_compressFilename (const char* outfilename, const char* infilename, const char* dictFileName, 76 int compressionLevel, ZSTD_compressionParameters comprParams); 77 78 /** FIO_decompressFilename() : 79 @return : 0 == ok; 1 == pb with src file. */ 80 int FIO_decompressFilename (const char* outfilename, const char* infilename, const char* dictFileName); 81 82 int FIO_listMultipleFiles(unsigned numFiles, const char** filenameTable, int displayLevel); 83 84 85 /*-************************************* 86 * Multiple File functions 87 ***************************************/ 88 /** FIO_compressMultipleFilenames() : 89 @return : nb of missing files */ 90 int FIO_compressMultipleFilenames(const char** srcNamesTable, unsigned nbFiles, 91 const char* outFileName, const char* suffix, 92 const char* dictFileName, int compressionLevel, 93 ZSTD_compressionParameters comprParams); 94 95 /** FIO_decompressMultipleFilenames() : 96 @return : nb of missing or skipped files */ 97 int FIO_decompressMultipleFilenames(const char** srcNamesTable, unsigned nbFiles, 98 const char* outFileName, 99 const char* dictFileName); 100 101 102 /*-************************************* 103 * Advanced stuff (should actually be hosted elsewhere) 104 ***************************************/ 105 106 /* custom crash signal handler */ 107 void FIO_addAbortHandler(void); 108 109 110 111 #if defined (__cplusplus) 112 } 113 #endif 114 115 #endif /* FILEIO_H_23981798732 */ 116