diff --git a/dap-sdk/core/include/dap_file_utils.h b/dap-sdk/core/include/dap_file_utils.h index d729966872df42ca6ac729e62441f344d80e281c..41a412dc114123897d65f1a56db720bfcddcbc7e 100755 --- a/dap-sdk/core/include/dap_file_utils.h +++ b/dap-sdk/core/include/dap_file_utils.h @@ -100,6 +100,7 @@ int dap_mkdir_with_parents(const char *a_dir_path); char* dap_path_get_basename(const char *a_file_name); bool dap_path_is_absolute(const char *a_file_name); char* dap_path_get_dirname(const char *a_file_name); +const char* dap_path_get_ext(const char *a_filename); /** * Get list of subdirectories diff --git a/dap-sdk/core/src/dap_file_utils.c b/dap-sdk/core/src/dap_file_utils.c index da36e8b5589d5b02edea9c0658ead0cd7d907251..d224211f6088ecdd32c431e6740447b73b854792 100755 --- a/dap-sdk/core/src/dap_file_utils.c +++ b/dap-sdk/core/src/dap_file_utils.c @@ -409,6 +409,34 @@ dap_list_name_directories_t *dap_get_subs(const char *a_path_dir){ return list; } + + + +/** + * dap_path_get_ext: + * @a_file_name: the name of the file + * + * Gets the extension components of a file name. + * + * Returns: the extension components of the file + */ +const char* dap_path_get_ext(const char *a_filename) +{ + size_t l_len = dap_strlen(a_filename); + const char *l_p = a_filename + l_len - 1; + if(l_len < 2) + return NULL ; + + while(l_p > a_filename) + { + if(*l_p == '.') { + return ++l_p; + } + l_p--; + } + return NULL ; +} + static bool get_contents_stdio(const char *filename, FILE *f, char **contents, size_t *length) { char buf[4096];