zstdcli: -r (operate recursively on directories) works with dictBuilder and compression
This commit is contained in:
parent
4f1acdd158
commit
957823f56f
@ -47,9 +47,7 @@ extern "C" {
|
|||||||
#include "zstd_static.h" /* ZSTD_parameters */
|
#include "zstd_static.h" /* ZSTD_parameters */
|
||||||
#include "zbuff.h"
|
#include "zbuff.h"
|
||||||
|
|
||||||
#ifndef MIN
|
#define ZBUFF_MIN(a,b) ((a)<(b) ? (a) : (b))
|
||||||
#define MIN(a,b) ((a)<(b) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*-*************************************
|
/*-*************************************
|
||||||
@ -73,7 +71,7 @@ ZSTDLIB_API size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* cctx,
|
|||||||
|
|
||||||
MEM_STATIC size_t ZBUFF_limitCopy(void* dst, size_t dstCapacity, const void* src, size_t srcSize)
|
MEM_STATIC size_t ZBUFF_limitCopy(void* dst, size_t dstCapacity, const void* src, size_t srcSize)
|
||||||
{
|
{
|
||||||
size_t length = MIN(dstCapacity, srcSize);
|
size_t length = ZBUFF_MIN(dstCapacity, srcSize);
|
||||||
memcpy(dst, src, length);
|
memcpy(dst, src, length);
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
/* *************************************
|
/* *************************************
|
||||||
* Includes
|
* Includes
|
||||||
***************************************/
|
***************************************/
|
||||||
#include "util.h" /* Compiler options, UTIL_GetFileSize, UTIL_HAS_CREATEFILELIST, UTIL_sleep */
|
#include "util.h" /* Compiler options, UTIL_GetFileSize, UTIL_sleep */
|
||||||
#include <stdlib.h> /* malloc, free */
|
#include <stdlib.h> /* malloc, free */
|
||||||
#include <string.h> /* memset */
|
#include <string.h> /* memset */
|
||||||
#include <stdio.h> /* fprintf, fopen, ftello64 */
|
#include <stdio.h> /* fprintf, fopen, ftello64 */
|
||||||
@ -495,32 +495,14 @@ static void BMK_syntheticTest(int cLevel, int cLevelLast, double compressibility
|
|||||||
|
|
||||||
|
|
||||||
int BMK_benchFiles(const char** fileNamesTable, unsigned nbFiles,
|
int BMK_benchFiles(const char** fileNamesTable, unsigned nbFiles,
|
||||||
const char* dictFileName, int cLevel, int cLevelLast, int recursive)
|
const char* dictFileName, int cLevel, int cLevelLast)
|
||||||
{
|
{
|
||||||
double const compressibility = (double)g_compressibilityDefault / 100;
|
double const compressibility = (double)g_compressibilityDefault / 100;
|
||||||
|
|
||||||
if (nbFiles == 0)
|
if (nbFiles == 0)
|
||||||
BMK_syntheticTest(cLevel, cLevelLast, compressibility);
|
BMK_syntheticTest(cLevel, cLevelLast, compressibility);
|
||||||
else
|
else
|
||||||
{
|
|
||||||
#ifdef UTIL_HAS_CREATEFILELIST
|
|
||||||
if (recursive) {
|
|
||||||
char* buf;
|
|
||||||
const char** filenameTable;
|
|
||||||
unsigned i;
|
|
||||||
filenameTable = UTIL_createFileList(fileNamesTable, nbFiles, &buf, &nbFiles);
|
|
||||||
if (filenameTable) {
|
|
||||||
for (i=0; i<nbFiles; i++) DISPLAYLEVEL(3, "%d %s\n", i, filenameTable[i]);
|
|
||||||
BMK_benchFileTable(filenameTable, nbFiles, dictFileName, cLevel, cLevelLast);
|
|
||||||
UTIL_freeFileList(filenameTable, buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else BMK_benchFileTable(fileNamesTable, nbFiles, dictFileName, cLevel, cLevelLast);
|
|
||||||
#else
|
|
||||||
(void)recursive;
|
|
||||||
BMK_benchFileTable(fileNamesTable, nbFiles, dictFileName, cLevel, cLevelLast);
|
BMK_benchFileTable(fileNamesTable, nbFiles, dictFileName, cLevel, cLevelLast);
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
/* Main function */
|
/* Main function */
|
||||||
int BMK_benchFiles(const char** fileNamesTable, unsigned nbFiles,
|
int BMK_benchFiles(const char** fileNamesTable, unsigned nbFiles,
|
||||||
const char* dictFileName, int cLevel, int cLevelLast, int recursive);
|
const char* dictFileName, int cLevel, int cLevelLast);
|
||||||
|
|
||||||
/* Set Parameters */
|
/* Set Parameters */
|
||||||
void BMK_SetNbIterations(unsigned nbLoops);
|
void BMK_SetNbIterations(unsigned nbLoops);
|
||||||
|
@ -345,8 +345,7 @@ UTIL_STATIC const char** UTIL_createFileList(const char **inputNames, unsigned i
|
|||||||
bufend = buf + LIST_SIZE_INCREASE;
|
bufend = buf + LIST_SIZE_INCREASE;
|
||||||
|
|
||||||
for (i=0, pos=0, nbFiles=0; i<inputNamesNb; i++) {
|
for (i=0, pos=0, nbFiles=0; i<inputNamesNb; i++) {
|
||||||
if (UTIL_doesFileExists(inputNames[i])) {
|
if (!UTIL_isDirectory(inputNames[i])) {
|
||||||
// printf ("UTIL_doesFileExists=[%s]\n", inputNames[i]);
|
|
||||||
size_t len = strlen(inputNames[i]);
|
size_t len = strlen(inputNames[i]);
|
||||||
if (buf + pos + len >= bufend) {
|
if (buf + pos + len >= bufend) {
|
||||||
ptrdiff_t newListSize = (bufend - buf) + LIST_SIZE_INCREASE;
|
ptrdiff_t newListSize = (bufend - buf) + LIST_SIZE_INCREASE;
|
||||||
|
@ -262,6 +262,8 @@ static size_t FUZ_randomLength(U32* seed, U32 maxLog)
|
|||||||
return FUZ_rLogLength(seed, logLength);
|
return FUZ_rLogLength(seed, logLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MIN(a,b) ( (a) < (b) ? (a) : (b) )
|
||||||
|
|
||||||
#define CHECK(cond, ...) if (cond) { DISPLAY("Error => "); DISPLAY(__VA_ARGS__); \
|
#define CHECK(cond, ...) if (cond) { DISPLAY("Error => "); DISPLAY(__VA_ARGS__); \
|
||||||
DISPLAY(" (seed %u, test nb %u) \n", seed, testNb); goto _output_error; }
|
DISPLAY(" (seed %u, test nb %u) \n", seed, testNb); goto _output_error; }
|
||||||
|
|
||||||
|
@ -129,6 +129,9 @@ static int usage_advanced(const char* programName)
|
|||||||
DISPLAY( " -v : verbose mode\n");
|
DISPLAY( " -v : verbose mode\n");
|
||||||
DISPLAY( " -q : suppress warnings; specify twice to suppress errors too\n");
|
DISPLAY( " -q : suppress warnings; specify twice to suppress errors too\n");
|
||||||
DISPLAY( " -c : force write to standard output, even if it is the console\n");
|
DISPLAY( " -c : force write to standard output, even if it is the console\n");
|
||||||
|
#ifdef UTIL_HAS_CREATEFILELIST
|
||||||
|
DISPLAY( " -r : operate recursively on directories\n");
|
||||||
|
#endif
|
||||||
#ifndef ZSTD_NOCOMPRESS
|
#ifndef ZSTD_NOCOMPRESS
|
||||||
DISPLAY( "--ultra : enable ultra modes (requires more memory to decompress)\n");
|
DISPLAY( "--ultra : enable ultra modes (requires more memory to decompress)\n");
|
||||||
#endif
|
#endif
|
||||||
@ -147,9 +150,6 @@ static int usage_advanced(const char* programName)
|
|||||||
DISPLAY( " -b# : benchmark file(s), using # compression level (default : 1) \n");
|
DISPLAY( " -b# : benchmark file(s), using # compression level (default : 1) \n");
|
||||||
DISPLAY( " -e# : test all compression levels from -bX to # (default: 1)\n");
|
DISPLAY( " -e# : test all compression levels from -bX to # (default: 1)\n");
|
||||||
DISPLAY( " -i# : iteration loops [1-9](default : 3)\n");
|
DISPLAY( " -i# : iteration loops [1-9](default : 3)\n");
|
||||||
#ifdef UTIL_HAS_CREATEFILELIST
|
|
||||||
DISPLAY( " -r : operate recursively on directories\n");
|
|
||||||
#endif
|
|
||||||
DISPLAY( " -B# : cut file into independent blocks of size # (default: no block)\n");
|
DISPLAY( " -B# : cut file into independent blocks of size # (default: no block)\n");
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
@ -198,6 +198,11 @@ int main(int argCount, const char** argv)
|
|||||||
unsigned maxDictSize = g_defaultMaxDictSize;
|
unsigned maxDictSize = g_defaultMaxDictSize;
|
||||||
unsigned dictCLevel = g_defaultDictCLevel;
|
unsigned dictCLevel = g_defaultDictCLevel;
|
||||||
unsigned dictSelect = g_defaultSelectivityLevel;
|
unsigned dictSelect = g_defaultSelectivityLevel;
|
||||||
|
#ifdef UTIL_HAS_CREATEFILELIST
|
||||||
|
const char** fileNamesTable = NULL;
|
||||||
|
char* fileNamesBuf;
|
||||||
|
unsigned fileNamesNb;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* init */
|
/* init */
|
||||||
(void)recursive; (void)cLevelLast; (void)dictCLevel; /* not used when ZSTD_NOBENCH / ZSTD_NODICT set */
|
(void)recursive; (void)cLevelLast; (void)dictCLevel; /* not used when ZSTD_NOBENCH / ZSTD_NODICT set */
|
||||||
@ -296,6 +301,9 @@ int main(int argCount, const char** argv)
|
|||||||
/* dictionary name */
|
/* dictionary name */
|
||||||
case 'o': nextArgumentIsOutFileName=1; argument++; break;
|
case 'o': nextArgumentIsOutFileName=1; argument++; break;
|
||||||
|
|
||||||
|
/* recursive */
|
||||||
|
case 'r': recursive=1; argument++; break;
|
||||||
|
|
||||||
#ifndef ZSTD_NOBENCH
|
#ifndef ZSTD_NOBENCH
|
||||||
/* Benchmark */
|
/* Benchmark */
|
||||||
case 'b': bench=1; argument++; break;
|
case 'b': bench=1; argument++; break;
|
||||||
@ -322,9 +330,6 @@ int main(int argCount, const char** argv)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* recursive */
|
|
||||||
case 'r': recursive=1; argument++; break;
|
|
||||||
|
|
||||||
/* cut input into blocks (benchmark only) */
|
/* cut input into blocks (benchmark only) */
|
||||||
case 'B':
|
case 'B':
|
||||||
{ size_t bSize = 0;
|
{ size_t bSize = 0;
|
||||||
@ -395,11 +400,24 @@ int main(int argCount, const char** argv)
|
|||||||
/* Welcome message (if verbose) */
|
/* Welcome message (if verbose) */
|
||||||
DISPLAYLEVEL(3, WELCOME_MESSAGE);
|
DISPLAYLEVEL(3, WELCOME_MESSAGE);
|
||||||
|
|
||||||
|
#ifdef UTIL_HAS_CREATEFILELIST
|
||||||
|
if (recursive) {
|
||||||
|
fileNamesTable = UTIL_createFileList(filenameTable, filenameIdx, &fileNamesBuf, &fileNamesNb);
|
||||||
|
if (fileNamesTable) {
|
||||||
|
unsigned i;
|
||||||
|
for (i=0; i<fileNamesNb; i++) DISPLAYLEVEL(3, "%d %s\n", i, fileNamesTable[i]);
|
||||||
|
free((void*)filenameTable);
|
||||||
|
filenameTable = fileNamesTable;
|
||||||
|
filenameIdx = fileNamesNb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Check if benchmark is selected */
|
/* Check if benchmark is selected */
|
||||||
if (bench) {
|
if (bench) {
|
||||||
#ifndef ZSTD_NOBENCH
|
#ifndef ZSTD_NOBENCH
|
||||||
BMK_setNotificationLevel(displayLevel);
|
BMK_setNotificationLevel(displayLevel);
|
||||||
BMK_benchFiles(filenameTable, filenameIdx, dictFileName, cLevel, cLevelLast, recursive);
|
BMK_benchFiles(filenameTable, filenameIdx, dictFileName, cLevel, cLevelLast);
|
||||||
#endif
|
#endif
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
@ -459,6 +477,11 @@ int main(int argCount, const char** argv)
|
|||||||
_end:
|
_end:
|
||||||
if (main_pause) waitEnter();
|
if (main_pause) waitEnter();
|
||||||
free(dynNameSpace);
|
free(dynNameSpace);
|
||||||
|
#ifdef UTIL_HAS_CREATEFILELIST
|
||||||
|
if (fileNamesTable)
|
||||||
|
UTIL_freeFileList(fileNamesTable, fileNamesBuf);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
free((void*)filenameTable);
|
free((void*)filenameTable);
|
||||||
return operationResult;
|
return operationResult;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user