Merge pull request #2032 from bimbashrestha/no-size
Adding --[no-]content-size to the cli
This commit is contained in:
commit
10f915f041
@ -323,6 +323,7 @@ struct FIO_prefs_s {
|
||||
|
||||
int excludeCompressedFiles;
|
||||
int patchFromMode;
|
||||
int contentSize;
|
||||
};
|
||||
|
||||
|
||||
@ -494,6 +495,11 @@ void FIO_setPatchFromMode(FIO_prefs_t* const prefs, int value)
|
||||
prefs->patchFromMode = value != 0;
|
||||
}
|
||||
|
||||
void FIO_setContentSize(FIO_prefs_t* const prefs, int value)
|
||||
{
|
||||
prefs->contentSize = value != 0;
|
||||
}
|
||||
|
||||
/*-*************************************
|
||||
* Functions
|
||||
***************************************/
|
||||
@ -817,6 +823,7 @@ static cRess_t FIO_createCResources(FIO_prefs_t* const prefs,
|
||||
CHECK( ZSTD_CCtx_setParameter(ress.cctx, ZSTD_c_contentSizeFlag, 1) ); /* always enable content size when available (note: supposed to be default) */
|
||||
CHECK( ZSTD_CCtx_setParameter(ress.cctx, ZSTD_c_dictIDFlag, prefs->dictIDFlag) );
|
||||
CHECK( ZSTD_CCtx_setParameter(ress.cctx, ZSTD_c_checksumFlag, prefs->checksumFlag) );
|
||||
CHECK( ZSTD_CCtx_setParameter(ress.cctx, ZSTD_c_contentSizeFlag, prefs->contentSize) );
|
||||
/* compression level */
|
||||
CHECK( ZSTD_CCtx_setParameter(ress.cctx, ZSTD_c_compressionLevel, cLevel) );
|
||||
/* max compressed block size */
|
||||
|
@ -95,6 +95,7 @@ void FIO_setNoProgress(unsigned noProgress);
|
||||
void FIO_setNotificationLevel(int level);
|
||||
void FIO_setExcludeCompressedFile(FIO_prefs_t* const prefs, int excludeCompressedFiles);
|
||||
void FIO_setPatchFromMode(FIO_prefs_t* const prefs, int value);
|
||||
void FIO_setContentSize(FIO_prefs_t* const prefs, int value);
|
||||
|
||||
/*-*************************************
|
||||
* Single File functions
|
||||
|
@ -198,6 +198,10 @@ the last one takes effect.
|
||||
default: enabled when output is into a file,
|
||||
and disabled when output is stdout.
|
||||
This setting overrides default and can force sparse mode over stdout.
|
||||
* `--[no-]content-size`:
|
||||
enable / disable whether or not the original size of the file is placed in
|
||||
the header of the compressed file. The default option is
|
||||
--content-size (meaning that the original size will be placed in the header).
|
||||
* `--rm`:
|
||||
remove source file(s) after successful compression or decompression
|
||||
* `-k`, `--keep`:
|
||||
|
@ -634,7 +634,8 @@ int main(int const argCount, const char* argv[])
|
||||
setRealTimePrio = 0,
|
||||
singleThread = 0,
|
||||
showDefaultCParams = 0,
|
||||
ultra=0;
|
||||
ultra=0,
|
||||
contentSize=1;
|
||||
double compressibility = 0.5;
|
||||
unsigned bench_nbSeconds = 3; /* would be better if this value was synchronized from bench */
|
||||
size_t blockSize = 0;
|
||||
@ -748,6 +749,8 @@ int main(int const argCount, const char* argv[])
|
||||
if (!strcmp(argument, "--priority=rt")) { setRealTimePrio = 1; continue; }
|
||||
if (!strcmp(argument, "--output-dir-flat")) {nextArgumentIsOutDirName=1; lastCommand=1; continue; }
|
||||
if (!strcmp(argument, "--show-default-cparams")) { showDefaultCParams = 1; continue; }
|
||||
if (!strcmp(argument, "--content-size")) { contentSize = 1; continue; }
|
||||
if (!strcmp(argument, "--no-content-size")) { contentSize = 0; continue; }
|
||||
if (!strcmp(argument, "--adapt")) { adapt = 1; continue; }
|
||||
if (longCommandWArg(&argument, "--adapt=")) { adapt = 1; if (!parseAdaptParameters(argument, &adaptMin, &adaptMax)) { badusage(programName); CLEAN_RETURN(1); } continue; }
|
||||
if (!strcmp(argument, "--single-thread")) { nbWorkers = 0; singleThread = 1; continue; }
|
||||
@ -1256,6 +1259,7 @@ int main(int const argCount, const char* argv[])
|
||||
FIO_setMemLimit(prefs, memLimit);
|
||||
if (operation==zom_compress) {
|
||||
#ifndef ZSTD_NOCOMPRESS
|
||||
FIO_setContentSize(prefs, contentSize);
|
||||
FIO_setNbWorkers(prefs, nbWorkers);
|
||||
FIO_setBlockSize(prefs, (int)blockSize);
|
||||
if (g_overlapLog!=OVERLAP_LOG_DEFAULT) FIO_setOverlapLog(prefs, (int)g_overlapLog);
|
||||
@ -1303,7 +1307,7 @@ int main(int const argCount, const char* argv[])
|
||||
else
|
||||
operationResult = FIO_compressMultipleFilenames(prefs, filenames->fileNames, (unsigned)filenames->tableSize, outDirName, outFileName, suffix, dictFileName, cLevel, compressionParams);
|
||||
#else
|
||||
(void)suffix; (void)adapt; (void)rsyncable; (void)ultra; (void)cLevel; (void)ldmFlag; (void)literalCompressionMode; (void)targetCBlockSize; (void)streamSrcSize; (void)srcSizeHint; (void)ZSTD_strategyMap; /* not used when ZSTD_NOCOMPRESS set */
|
||||
(void)contentSize; (void)suffix; (void)adapt; (void)rsyncable; (void)ultra; (void)cLevel; (void)ldmFlag; (void)literalCompressionMode; (void)targetCBlockSize; (void)streamSrcSize; (void)srcSizeHint; (void)ZSTD_strategyMap; /* not used when ZSTD_NOCOMPRESS set */
|
||||
DISPLAY("Compression not supported \n");
|
||||
#endif
|
||||
} else { /* decompression or test */
|
||||
|
@ -469,6 +469,19 @@ ls tmp* > tmpList
|
||||
$ZSTD -f tmp1 --filelist=tmpList --filelist=tmpList tmp2 tmp3 # can trigger an overflow of internal file list
|
||||
rm -rf tmp*
|
||||
|
||||
println "\n===> --[no-]content-size tests"
|
||||
|
||||
$DATAGEN > tmp_contentsize
|
||||
$ZSTD -f tmp_contentsize
|
||||
$ZSTD -lv tmp_contentsize.zst | grep "Decompressed Size:"
|
||||
$ZSTD -f --no-content-size tmp_contentsize
|
||||
$ZSTD -lv tmp_contentsize.zst | grep "Decompressed Size:" && die
|
||||
$ZSTD -f --content-size tmp_contentsize
|
||||
$ZSTD -lv tmp_contentsize.zst | grep "Decompressed Size:"
|
||||
$ZSTD -f --content-size --no-content-size tmp_contentsize
|
||||
$ZSTD -lv tmp_contentsize.zst | grep "Decompressed Size:" && die
|
||||
rm -rf tmp*
|
||||
|
||||
println "test : show-default-cparams regular"
|
||||
$DATAGEN > tmp
|
||||
$ZSTD --show-default-cparams -f tmp
|
||||
|
Loading…
Reference in New Issue
Block a user