Created utility function to extract extension from filename, fixed tests
This commit is contained in:
parent
5e6dbad6c1
commit
9ab6a747d4
@ -1430,6 +1430,9 @@ static int FIO_compressFilename_dstFile(FIO_prefs_t* const prefs,
|
||||
return result;
|
||||
}
|
||||
|
||||
/* List used to compare file extensions (used with --exclude-compressed flag)
|
||||
* Different from the suffixList and should only apply to ZSTD compress operationResult
|
||||
*/
|
||||
static const char *compressedFileExtensions[] = {
|
||||
ZSTD_EXTENSION,
|
||||
TZSTD_EXTENSION,
|
||||
|
@ -326,23 +326,32 @@ int UTIL_prepareFileList(const char *dirName, char** bufStart, size_t* pos, char
|
||||
|
||||
#endif /* #ifdef _WIN32 */
|
||||
|
||||
/* Check if the file is precompressed (.zst, .lz4, .gz, .xz).
|
||||
YES => Skip the file (return 0)
|
||||
NO => return 1
|
||||
/* Check if the file is Compressed by comparing it with compressFileExtension list.
|
||||
YES => Skip the file (return 1)
|
||||
NO => return 0
|
||||
*/
|
||||
|
||||
int UTIL_isCompressedFile(const char *inputName, const char *extensionList[])
|
||||
{
|
||||
const char* ext = UTIL_getFileExtension(inputName);
|
||||
while(*extensionList!=NULL)
|
||||
{
|
||||
const char* ext = strstr(inputName,*extensionList);
|
||||
if(ext)
|
||||
const char* isCompressedExtension = strstr(ext,*extensionList);
|
||||
if(isCompressedExtension)
|
||||
return 1;
|
||||
++extensionList;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*Utility function to get file extension from file */
|
||||
const char* UTIL_getFileExtension(const char* infilename)
|
||||
{
|
||||
const char* extension = strrchr(infilename, '.');
|
||||
if(!extension || extension==infilename) return "";
|
||||
return extension;
|
||||
}
|
||||
|
||||
/*
|
||||
* UTIL_createFileList - takes a list of files and directories (params: inputNames, inputNamesNb), scans directories,
|
||||
* and returns a new list of files (params: return value, allocatedBuffer, allocatedNamesNb).
|
||||
|
@ -135,6 +135,8 @@ 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_isCompressedFile(const char* infilename, const char *extensionList[]);
|
||||
const char* UTIL_getFileExtension(const char* infilename);
|
||||
|
||||
U32 UTIL_isFIFO(const char* infilename);
|
||||
U32 UTIL_isLink(const char* infilename);
|
||||
#define UTIL_FILESIZE_UNKNOWN ((U64)(-1))
|
||||
|
@ -230,12 +230,11 @@ test ! -f input.6.zst.zst
|
||||
file1timestamp=`date -r precompressedFilterTestDir/input.5.zst +%s`
|
||||
file2timestamp=`date -r precompressedFilterTestDir/input.7.zst +%s`
|
||||
if [[ $file2timestamp -ge $file1timestamp ]]; then
|
||||
println "Test is successful. input.5.zst is not precompressed and therefore not compressed/modified again."
|
||||
println "Test is successful. input.5.zst is precompressed and therefore not compressed/modified again."
|
||||
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
Block a user