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