2017-08-18 23:52:05 +00:00
|
|
|
/*
|
2016-08-30 17:04:33 +00:00
|
|
|
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
2017-08-18 23:52:05 +00:00
|
|
|
* This source code is licensed under both the BSD-style license (found in the
|
|
|
|
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
|
|
|
* in the COPYING file in the root directory of this source tree).
|
2017-09-08 07:09:23 +00:00
|
|
|
* You may select, at your option, one of the above-listed licenses.
|
2016-08-30 17:04:33 +00:00
|
|
|
*/
|
2015-01-31 09:52:59 +00:00
|
|
|
|
|
|
|
|
2016-09-15 15:02:06 +00:00
|
|
|
#ifndef FILEIO_H_23981798732
|
|
|
|
#define FILEIO_H_23981798732
|
2015-01-31 09:52:59 +00:00
|
|
|
|
2016-12-13 12:24:59 +00:00
|
|
|
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_compressionParameters */
|
2017-01-26 01:01:13 +00:00
|
|
|
#include "zstd.h" /* ZSTD_* */
|
2016-12-13 12:24:59 +00:00
|
|
|
|
2015-01-31 09:52:59 +00:00
|
|
|
#if defined (__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-01-26 01:01:13 +00:00
|
|
|
|
2015-10-22 14:31:46 +00:00
|
|
|
/* *************************************
|
2015-01-31 09:52:59 +00:00
|
|
|
* Special i/o constants
|
|
|
|
**************************************/
|
2016-12-02 23:18:57 +00:00
|
|
|
#define stdinmark "/*stdin*\\"
|
2016-11-04 10:37:27 +00:00
|
|
|
#define stdoutmark "/*stdout*\\"
|
2015-01-31 09:52:59 +00:00
|
|
|
#ifdef _WIN32
|
2019-10-17 23:39:47 +00:00
|
|
|
# define nulmark "NUL"
|
2015-01-31 09:52:59 +00:00
|
|
|
#else
|
|
|
|
# define nulmark "/dev/null"
|
|
|
|
#endif
|
2017-03-14 01:11:07 +00:00
|
|
|
#define LZMA_EXTENSION ".lzma"
|
|
|
|
#define XZ_EXTENSION ".xz"
|
|
|
|
#define GZ_EXTENSION ".gz"
|
|
|
|
#define ZSTD_EXTENSION ".zst"
|
2017-04-24 23:48:25 +00:00
|
|
|
#define LZ4_EXTENSION ".lz4"
|
2015-01-31 09:52:59 +00:00
|
|
|
|
|
|
|
|
2017-02-08 14:17:55 +00:00
|
|
|
/*-*************************************
|
|
|
|
* Types
|
|
|
|
***************************************/
|
2017-04-24 23:48:25 +00:00
|
|
|
typedef enum { FIO_zstdCompression, FIO_gzipCompression, FIO_xzCompression, FIO_lzmaCompression, FIO_lz4Compression } FIO_compressionType_t;
|
2017-02-08 14:17:55 +00:00
|
|
|
|
2019-01-23 01:31:13 +00:00
|
|
|
typedef struct FIO_prefs_s FIO_prefs_t;
|
|
|
|
|
|
|
|
FIO_prefs_t* FIO_createPreferences(void);
|
|
|
|
void FIO_freePreferences(FIO_prefs_t* const prefs);
|
|
|
|
|
|
|
|
typedef struct FIO_display_prefs_s FIO_display_prefs_t;
|
2017-02-08 14:17:55 +00:00
|
|
|
|
2016-03-10 20:02:25 +00:00
|
|
|
/*-*************************************
|
2015-01-31 09:52:59 +00:00
|
|
|
* Parameters
|
2015-10-22 14:31:46 +00:00
|
|
|
***************************************/
|
2019-01-23 01:31:13 +00:00
|
|
|
void FIO_setCompressionType(FIO_prefs_t* const prefs, FIO_compressionType_t compressionType);
|
|
|
|
void FIO_overwriteMode(FIO_prefs_t* const prefs);
|
|
|
|
void FIO_setAdaptiveMode(FIO_prefs_t* const prefs, unsigned adapt);
|
|
|
|
void FIO_setAdaptMin(FIO_prefs_t* const prefs, int minCLevel);
|
|
|
|
void FIO_setAdaptMax(FIO_prefs_t* const prefs, int maxCLevel);
|
2019-01-25 22:42:44 +00:00
|
|
|
void FIO_setBlockSize(FIO_prefs_t* const prefs, int blockSize);
|
|
|
|
void FIO_setChecksumFlag(FIO_prefs_t* const prefs, int checksumFlag);
|
|
|
|
void FIO_setDictIDFlag(FIO_prefs_t* const prefs, int dictIDFlag);
|
|
|
|
void FIO_setLdmBucketSizeLog(FIO_prefs_t* const prefs, int ldmBucketSizeLog);
|
2019-01-23 01:31:13 +00:00
|
|
|
void FIO_setLdmFlag(FIO_prefs_t* const prefs, unsigned ldmFlag);
|
2019-01-25 22:42:44 +00:00
|
|
|
void FIO_setLdmHashRateLog(FIO_prefs_t* const prefs, int ldmHashRateLog);
|
|
|
|
void FIO_setLdmHashLog(FIO_prefs_t* const prefs, int ldmHashLog);
|
|
|
|
void FIO_setLdmMinMatch(FIO_prefs_t* const prefs, int ldmMinMatch);
|
2019-01-23 01:31:13 +00:00
|
|
|
void FIO_setMemLimit(FIO_prefs_t* const prefs, unsigned memLimit);
|
2019-01-25 22:42:44 +00:00
|
|
|
void FIO_setNbWorkers(FIO_prefs_t* const prefs, int nbWorkers);
|
|
|
|
void FIO_setOverlapLog(FIO_prefs_t* const prefs, int overlapLog);
|
2019-01-23 01:31:13 +00:00
|
|
|
void FIO_setRemoveSrcFile(FIO_prefs_t* const prefs, unsigned flag);
|
|
|
|
void FIO_setSparseWrite(FIO_prefs_t* const prefs, unsigned sparse); /**< 0: no sparse; 1: disable on stdout; 2: always enabled */
|
2019-01-25 22:42:44 +00:00
|
|
|
void FIO_setRsyncable(FIO_prefs_t* const prefs, int rsyncable);
|
2019-08-16 06:57:55 +00:00
|
|
|
void FIO_setStreamSrcSize(FIO_prefs_t* const prefs, size_t streamSrcSize);
|
2019-06-24 20:40:52 +00:00
|
|
|
void FIO_setTargetCBlockSize(FIO_prefs_t* const prefs, size_t targetCBlockSize);
|
2019-08-19 15:52:08 +00:00
|
|
|
void FIO_setSrcSizeHint(FIO_prefs_t* const prefs, size_t srcSizeHint);
|
2019-10-17 23:09:53 +00:00
|
|
|
void FIO_setTestMode(FIO_prefs_t* const prefs, int testMode);
|
2019-02-15 22:15:36 +00:00
|
|
|
void FIO_setLiteralCompressionMode(
|
|
|
|
FIO_prefs_t* const prefs,
|
|
|
|
ZSTD_literalCompressionMode_e mode);
|
2015-01-31 09:52:59 +00:00
|
|
|
|
2019-01-23 01:31:13 +00:00
|
|
|
void FIO_setNoProgress(unsigned noProgress);
|
2019-01-25 22:42:44 +00:00
|
|
|
void FIO_setNotificationLevel(int level);
|
2015-01-31 09:52:59 +00:00
|
|
|
|
2016-03-10 20:02:25 +00:00
|
|
|
/*-*************************************
|
2015-12-17 01:23:58 +00:00
|
|
|
* Single File functions
|
2015-10-22 14:31:46 +00:00
|
|
|
***************************************/
|
2016-02-12 02:50:05 +00:00
|
|
|
/** FIO_compressFilename() :
|
2019-10-17 23:09:53 +00:00
|
|
|
* @return : 0 == ok; 1 == pb with src file. */
|
2019-01-23 01:31:13 +00:00
|
|
|
int FIO_compressFilename (FIO_prefs_t* const prefs,
|
2019-09-05 23:03:35 +00:00
|
|
|
const char* outfilename, const char* infilename,
|
|
|
|
const char* dictFileName, int compressionLevel,
|
|
|
|
ZSTD_compressionParameters comprParams);
|
2015-01-31 09:52:59 +00:00
|
|
|
|
2016-02-12 02:50:05 +00:00
|
|
|
/** FIO_decompressFilename() :
|
2019-10-17 23:09:53 +00:00
|
|
|
* @return : 0 == ok; 1 == pb with src file. */
|
2019-01-23 01:31:13 +00:00
|
|
|
int FIO_decompressFilename (FIO_prefs_t* const prefs,
|
|
|
|
const char* outfilename, const char* infilename, const char* dictFileName);
|
2015-01-31 09:52:59 +00:00
|
|
|
|
2017-06-20 19:43:10 +00:00
|
|
|
int FIO_listMultipleFiles(unsigned numFiles, const char** filenameTable, int displayLevel);
|
2015-01-31 09:52:59 +00:00
|
|
|
|
2018-09-25 01:16:08 +00:00
|
|
|
|
2016-03-10 20:02:25 +00:00
|
|
|
/*-*************************************
|
2015-12-17 01:23:58 +00:00
|
|
|
* Multiple File functions
|
|
|
|
***************************************/
|
2016-02-12 02:50:05 +00:00
|
|
|
/** FIO_compressMultipleFilenames() :
|
2019-10-17 23:09:53 +00:00
|
|
|
* @return : nb of missing files */
|
2019-10-17 22:32:03 +00:00
|
|
|
int FIO_compressMultipleFilenames(FIO_prefs_t* const prefs,
|
|
|
|
const char** inFileNamesTable, unsigned nbFiles,
|
|
|
|
const char* outDirName,
|
|
|
|
const char* outFileName, const char* suffix,
|
|
|
|
const char* dictFileName, int compressionLevel,
|
2019-10-03 17:53:04 +00:00
|
|
|
ZSTD_compressionParameters comprParams);
|
2016-02-12 02:50:05 +00:00
|
|
|
|
|
|
|
/** FIO_decompressMultipleFilenames() :
|
2019-10-17 23:09:53 +00:00
|
|
|
* @return : nb of missing or skipped files */
|
2019-01-23 01:31:13 +00:00
|
|
|
int FIO_decompressMultipleFilenames(FIO_prefs_t* const prefs,
|
|
|
|
const char** srcNamesTable, unsigned nbFiles,
|
2019-10-03 17:53:04 +00:00
|
|
|
const char* outDirName,
|
2017-12-13 02:32:50 +00:00
|
|
|
const char* outFileName,
|
2015-12-17 19:30:14 +00:00
|
|
|
const char* dictFileName);
|
2015-12-17 01:23:58 +00:00
|
|
|
|
2019-10-03 17:53:04 +00:00
|
|
|
/* FIO_checkFilenameCollisions() :
|
2019-10-17 23:09:53 +00:00
|
|
|
* Checks for and warns if there are any files that would have the same output path
|
2019-10-03 17:53:04 +00:00
|
|
|
*/
|
|
|
|
int FIO_checkFilenameCollisions(const char** filenameTable, unsigned nbFiles);
|
2015-01-31 09:52:59 +00:00
|
|
|
|
2019-10-17 23:09:53 +00:00
|
|
|
|
|
|
|
|
2018-09-25 01:16:08 +00:00
|
|
|
/*-*************************************
|
|
|
|
* Advanced stuff (should actually be hosted elsewhere)
|
|
|
|
***************************************/
|
|
|
|
|
2018-09-11 18:39:49 +00:00
|
|
|
/* custom crash signal handler */
|
|
|
|
void FIO_addAbortHandler(void);
|
|
|
|
|
2018-09-25 01:16:08 +00:00
|
|
|
|
|
|
|
|
2015-01-31 09:52:59 +00:00
|
|
|
#if defined (__cplusplus)
|
|
|
|
}
|
2015-10-22 14:31:46 +00:00
|
|
|
#endif
|
2016-09-15 15:02:06 +00:00
|
|
|
|
|
|
|
#endif /* FILEIO_H_23981798732 */
|