1 /*
2 * Copyright (c) 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 "../lib/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
34 /**
35 * We test whether the extension we found starts with 't', and if so, we append
36 * ".tar" to the end of the output name.
37 */
38 #define LZMA_EXTENSION ".lzma"
39 #define XZ_EXTENSION ".xz"
40 #define TXZ_EXTENSION ".txz"
41
42 #define GZ_EXTENSION ".gz"
43 #define TGZ_EXTENSION ".tgz"
44
45 #define ZSTD_EXTENSION ".zst"
46 #define TZSTD_EXTENSION ".tzst"
47 #define ZSTD_ALT_EXTENSION ".zstd" /* allow decompression of .zstd files */
48
49 #define LZ4_EXTENSION ".lz4"
50 #define TLZ4_EXTENSION ".tlz4"
51
52
53 /*-*************************************
54 * Types
55 ***************************************/
56 typedef enum { FIO_zstdCompression, FIO_gzipCompression, FIO_xzCompression, FIO_lzmaCompression, FIO_lz4Compression } FIO_compressionType_t;
57
58 typedef struct FIO_prefs_s FIO_prefs_t;
59
60 FIO_prefs_t* FIO_createPreferences(void);
61 void FIO_freePreferences(FIO_prefs_t* const prefs);
62
63 /* Mutable struct containing relevant context and state regarding (de)compression with respect to file I/O */
64 typedef struct FIO_ctx_s FIO_ctx_t;
65
66 FIO_ctx_t* FIO_createContext(void);
67 void FIO_freeContext(FIO_ctx_t* const fCtx);
68
69 typedef struct FIO_display_prefs_s FIO_display_prefs_t;
70
71 typedef enum { FIO_ps_auto, FIO_ps_never, FIO_ps_always } FIO_progressSetting_e;
72
73 /*-*************************************
74 * Parameters
75 ***************************************/
76 /* FIO_prefs_t functions */
77 void FIO_setCompressionType(FIO_prefs_t* const prefs, FIO_compressionType_t compressionType);
78 void FIO_overwriteMode(FIO_prefs_t* const prefs);
79 void FIO_setAdaptiveMode(FIO_prefs_t* const prefs, unsigned adapt);
80 void FIO_setAdaptMin(FIO_prefs_t* const prefs, int minCLevel);
81 void FIO_setAdaptMax(FIO_prefs_t* const prefs, int maxCLevel);
82 void FIO_setUseRowMatchFinder(FIO_prefs_t* const prefs, int useRowMatchFinder);
83 void FIO_setBlockSize(FIO_prefs_t* const prefs, int blockSize);
84 void FIO_setChecksumFlag(FIO_prefs_t* const prefs, int checksumFlag);
85 void FIO_setDictIDFlag(FIO_prefs_t* const prefs, int dictIDFlag);
86 void FIO_setLdmBucketSizeLog(FIO_prefs_t* const prefs, int ldmBucketSizeLog);
87 void FIO_setLdmFlag(FIO_prefs_t* const prefs, unsigned ldmFlag);
88 void FIO_setLdmHashRateLog(FIO_prefs_t* const prefs, int ldmHashRateLog);
89 void FIO_setLdmHashLog(FIO_prefs_t* const prefs, int ldmHashLog);
90 void FIO_setLdmMinMatch(FIO_prefs_t* const prefs, int ldmMinMatch);
91 void FIO_setMemLimit(FIO_prefs_t* const prefs, unsigned memLimit);
92 void FIO_setNbWorkers(FIO_prefs_t* const prefs, int nbWorkers);
93 void FIO_setOverlapLog(FIO_prefs_t* const prefs, int overlapLog);
94 void FIO_setRemoveSrcFile(FIO_prefs_t* const prefs, unsigned flag);
95 void FIO_setSparseWrite(FIO_prefs_t* const prefs, unsigned sparse); /**< 0: no sparse; 1: disable on stdout; 2: always enabled */
96 void FIO_setRsyncable(FIO_prefs_t* const prefs, int rsyncable);
97 void FIO_setStreamSrcSize(FIO_prefs_t* const prefs, size_t streamSrcSize);
98 void FIO_setTargetCBlockSize(FIO_prefs_t* const prefs, size_t targetCBlockSize);
99 void FIO_setSrcSizeHint(FIO_prefs_t* const prefs, size_t srcSizeHint);
100 void FIO_setTestMode(FIO_prefs_t* const prefs, int testMode);
101 void FIO_setLiteralCompressionMode(
102 FIO_prefs_t* const prefs,
103 ZSTD_paramSwitch_e mode);
104
105 void FIO_setProgressSetting(FIO_progressSetting_e progressSetting);
106 void FIO_setNotificationLevel(int level);
107 void FIO_setExcludeCompressedFile(FIO_prefs_t* const prefs, int excludeCompressedFiles);
108 void FIO_setAllowBlockDevices(FIO_prefs_t* const prefs, int allowBlockDevices);
109 void FIO_setPatchFromMode(FIO_prefs_t* const prefs, int value);
110 void FIO_setContentSize(FIO_prefs_t* const prefs, int value);
111 void FIO_displayCompressionParameters(const FIO_prefs_t* prefs);
112
113 /* FIO_ctx_t functions */
114 void FIO_setNbFilesTotal(FIO_ctx_t* const fCtx, int value);
115 void FIO_setHasStdoutOutput(FIO_ctx_t* const fCtx, int value);
116 void FIO_determineHasStdinInput(FIO_ctx_t* const fCtx, const FileNamesTable* const filenames);
117
118 /*-*************************************
119 * Single File functions
120 ***************************************/
121 /** FIO_compressFilename() :
122 * @return : 0 == ok; 1 == pb with src file. */
123 int FIO_compressFilename (FIO_ctx_t* const fCtx, FIO_prefs_t* const prefs,
124 const char* outfilename, const char* infilename,
125 const char* dictFileName, int compressionLevel,
126 ZSTD_compressionParameters comprParams);
127
128 /** FIO_decompressFilename() :
129 * @return : 0 == ok; 1 == pb with src file. */
130 int FIO_decompressFilename (FIO_ctx_t* const fCtx, FIO_prefs_t* const prefs,
131 const char* outfilename, const char* infilename, const char* dictFileName);
132
133 int FIO_listMultipleFiles(unsigned numFiles, const char** filenameTable, int displayLevel);
134
135
136 /*-*************************************
137 * Multiple File functions
138 ***************************************/
139 /** FIO_compressMultipleFilenames() :
140 * @return : nb of missing files */
141 int FIO_compressMultipleFilenames(FIO_ctx_t* const fCtx,
142 FIO_prefs_t* const prefs,
143 const char** inFileNamesTable,
144 const char* outMirroredDirName,
145 const char* outDirName,
146 const char* outFileName, const char* suffix,
147 const char* dictFileName, int compressionLevel,
148 ZSTD_compressionParameters comprParams);
149
150 /** FIO_decompressMultipleFilenames() :
151 * @return : nb of missing or skipped files */
152 int FIO_decompressMultipleFilenames(FIO_ctx_t* const fCtx,
153 FIO_prefs_t* const prefs,
154 const char** srcNamesTable,
155 const char* outMirroredDirName,
156 const char* outDirName,
157 const char* outFileName,
158 const char* dictFileName);
159
160 /* FIO_checkFilenameCollisions() :
161 * Checks for and warns if there are any files that would have the same output path
162 */
163 int FIO_checkFilenameCollisions(const char** filenameTable, unsigned nbFiles);
164
165
166
167 /*-*************************************
168 * Advanced stuff (should actually be hosted elsewhere)
169 ***************************************/
170
171 /* custom crash signal handler */
172 void FIO_addAbortHandler(void);
173
174
175
176 #if defined (__cplusplus)
177 }
178 #endif
179
180 #endif /* FILEIO_H_23981798732 */
Cache object: 53b93f524eeebb246c62421b21f8adcb
|