Addressing comments: -Created a list of extensions defined in fileio.h, -Updated test
parent
48f856640e
commit
02433e0b15
|
@ -1453,8 +1453,13 @@ FIO_compressFilename_srcFile(FIO_prefs_t* const prefs,
|
|||
|
||||
ress.srcFile = FIO_openSrcFile(srcFileName);
|
||||
if (ress.srcFile == NULL) return 1; /* srcFile could not be opened */
|
||||
if (g_excludeCompressedFiles && !UTIL_isPrecompressedFile(srcFileName)) { /* precompressed file (--exclude-compressed). DO NOT COMPRESS */
|
||||
DISPLAYLEVEL(4, "Precompressed file: %s \n", srcFileName);
|
||||
|
||||
/* Check if "srcFile" is compressed. Only done if --exclude-compressed flag is used
|
||||
* YES => ZSTD will not compress the file.
|
||||
* NO => ZSTD will resume with compress operation.
|
||||
*/
|
||||
if (g_excludeCompressedFiles && UTIL_isCompressedFile(srcFileName)) { /* precompressed file (--exclude-compressed). DO NOT COMPRESS */
|
||||
DISPLAYLEVEL(4, "File is already compressed : %s \n", srcFileName);
|
||||
fclose(ress.srcFile);
|
||||
ress.srcFile = NULL;
|
||||
return 0;
|
||||
|
|
|
@ -330,22 +330,21 @@ int UTIL_prepareFileList(const char *dirName, char** bufStart, size_t* pos, char
|
|||
YES => Skip the file (return 0)
|
||||
NO => return 1
|
||||
*/
|
||||
int UTIL_isPrecompressedFile(const char *inputName)
|
||||
int UTIL_isCompressedFile(const char *inputName)
|
||||
{
|
||||
return compareExtensions(inputName,compressedFileExtensions);
|
||||
return compareExtensions(inputName,g_compressedFileExtensions);
|
||||
}
|
||||
|
||||
int compareExtensions(const char* infilename, const char extensionList[4][10])
|
||||
int compareExtensions(const char* infilename, const char* extensionList[])
|
||||
{
|
||||
int i=0;
|
||||
//char* ext = strchr(infilename, '.');
|
||||
for(i=0;i<4;i++)
|
||||
while(*extensionList != NULL)
|
||||
{
|
||||
char* ext = strstr(infilename,extensionList[i]);
|
||||
const char* ext = strstr(infilename,extensionList[i]);
|
||||
if(ext)
|
||||
return 0;
|
||||
return 1;
|
||||
++extensionList;
|
||||
}
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* UTIL_createFileList - takes a list of files and directories (params: inputNames, inputNamesNb), scans directories,
|
||||
|
|
|
@ -39,7 +39,7 @@ extern "C" {
|
|||
#endif
|
||||
#include <time.h> /* clock_t, clock, CLOCKS_PER_SEC, nanosleep */
|
||||
#include "mem.h" /* U32, U64 */
|
||||
|
||||
#include "fileio.h"
|
||||
|
||||
/*-************************************************************
|
||||
* Avoid fseek()'s 2GiB barrier with MSVC, macOS, *BSD, MinGW
|
||||
|
@ -128,7 +128,18 @@ extern int g_utilDisplayLevel;
|
|||
#endif
|
||||
|
||||
int g_excludeCompressedFiles;
|
||||
static const char compressedFileExtensions[4][10] = {".zst",".gz",".xz",".lz4"};
|
||||
static const char *g_compressedFileExtensions[] = {
|
||||
ZSTD_EXTENSION,
|
||||
TZSTD_EXTENSION,
|
||||
GZ_EXTENSION,
|
||||
TGZ_EXTENSION,
|
||||
LZMA_EXTENSION,
|
||||
XZ_EXTENSION,
|
||||
TXZ_EXTENSION,
|
||||
LZ4_EXTENSION,
|
||||
TLZ4_EXTENSION,
|
||||
NULL
|
||||
};
|
||||
|
||||
int UTIL_fileExist(const char* filename);
|
||||
int UTIL_isRegularFile(const char* infilename);
|
||||
|
@ -137,8 +148,8 @@ U32 UTIL_isDirectory(const char* infilename);
|
|||
int UTIL_getFileStat(const char* infilename, stat_t* statbuf);
|
||||
int UTIL_isSameFile(const char* file1, const char* file2);
|
||||
int UTIL_compareStr(const void *p1, const void *p2);
|
||||
int UTIL_isPrecompressedFile(const char* infilename);
|
||||
int compareExtensions(const char* infilename, const char extensionList[4][10]);
|
||||
int UTIL_isCompressedFile(const char* infilename);
|
||||
int compareExtensions(const char* infilename, const char *extensionList[]);
|
||||
|
||||
U32 UTIL_isFIFO(const char* infilename);
|
||||
U32 UTIL_isLink(const char* infilename);
|
||||
|
|
|
@ -118,7 +118,6 @@ static int usage(const char* programName)
|
|||
#endif
|
||||
DISPLAY( " -D file: use `file` as Dictionary \n");
|
||||
DISPLAY( " -o file: result stored into `file` (only if 1 input file) \n");
|
||||
DISPLAY( "--exclude-compressed: only compress files that are not previously compressed \n");
|
||||
DISPLAY( " -f : overwrite output without prompting and (de)compress links \n");
|
||||
DISPLAY( "--rm : remove source file(s) after successful de/compression \n");
|
||||
DISPLAY( " -k : preserve source file(s) (default) \n");
|
||||
|
@ -137,6 +136,7 @@ static int usage_advanced(const char* programName)
|
|||
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( " -l : print information about zstd compressed files \n");
|
||||
DISPLAY( "--exclude-compressed: only compress files that are not previously compressed \n");
|
||||
#ifndef ZSTD_NOCOMPRESS
|
||||
DISPLAY( "--ultra : enable levels beyond %i, up to %i (requires more memory)\n", ZSTDCLI_CLEVEL_MAX, ZSTD_maxCLevel());
|
||||
DISPLAY( "--long[=#]: enable long distance matching with given window log (default: %u)\n", g_defaultMaxWindowLog);
|
||||
|
|
|
@ -232,7 +232,6 @@ else
|
|||
println "Test is not successful"
|
||||
fi
|
||||
println "Test completed"
|
||||
sleep 5
|
||||
|
||||
println "test : file removal"
|
||||
$ZSTD -f --rm tmp
|
||||
|
|
Loading…
Reference in New Issue