Created utility function to extract extension from filename, fixed tests
diff --git a/programs/util.c b/programs/util.c
index 7212f7b..f6933bc 100644
--- a/programs/util.c
+++ b/programs/util.c
@@ -326,23 +326,32 @@
#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).