diff --git a/include/dap_file_utils.h b/include/dap_file_utils.h index 81e22d8a51093afba5584525fd9e04253d6b0e16..2a85b162d14890be91f3f06306e4fc4f5ad386c4 100755 --- a/include/dap_file_utils.h +++ b/include/dap_file_utils.h @@ -22,6 +22,8 @@ along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. */ #include <stdbool.h> +#include "dap_list.h" +#include <dirent.h> #ifndef _DAP_FILE_UTILS_H_ #define _DAP_FILE_UTILS_H_ @@ -85,4 +87,6 @@ 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); +dap_list_t *dap_dir_get_subdirectory(const char *a_path_name); + #endif // _FILE_UTILS_H_ diff --git a/src/dap_file_utils.c b/src/dap_file_utils.c index 2ad83ad15c39b8f9418ee30a9790930e3db1bf91..3826922e9b4ff635a20c185213edad9fb8b6bf31 100755 --- a/src/dap_file_utils.c +++ b/src/dap_file_utils.c @@ -368,3 +368,17 @@ char* dap_path_get_dirname(const char *a_file_name) return l_base; } + +dap_list_t *dap_dir_get_subdirectory(const char *a_path_dir){ + dap_list_t *list = dap_list_alloc(); + DIR *dir = opendir(a_path_dir); + struct dirent *entry = readdir(dir); + while (entry != NULL){ + if (strcmp(entry->d_name, "..") != 0 && strcmp(entry->d_name, ".") != 0 && entry->d_type == DT_DIR){ + dap_list_append(list, entry->d_name); + } + entry = readdir(dir); + } + closedir(dir); + return list; +}