Skip to content
Snippets Groups Projects
Commit 76f2e3f1 authored by alexey.stratulat's avatar alexey.stratulat
Browse files

[+] Added function has been added to identify all subdirectories in a...

[+] Added function has been added to identify all subdirectories in a directory in the Linux family operating system.
parent 50bbcf37
No related branches found
No related tags found
1 merge request!33Features 2954
......@@ -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_
......@@ -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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment