diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-01-22 02:24:44 +0100 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-01-22 02:24:44 +0100 |
| commit | 069301a603ad07338179bafed0c35b6fe3b372f2 (patch) | |
| tree | 74010f542968876938d18effe8939694ddafdc03 /list.c | |
| parent | ac3c52c4431d422affe951ff0641b4eb04787e54 (diff) | |
| download | crep-069301a603ad07338179bafed0c35b6fe3b372f2.tar.gz | |
Better arg parsing
Diffstat (limited to 'list.c')
| -rw-r--r-- | list.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -22,7 +22,7 @@ void add_file_path(Node **head, char *file_path) { *head = new; } -void list_files_recursively(char *base_path, Node **head) { +void list_files_recursively(char *base_path, Node **head, int max_depth, int current_depth) { struct stat statbuf; if (stat(base_path, &statbuf) == -1) { perror("stat"); @@ -52,7 +52,9 @@ void list_files_recursively(char *base_path, Node **head) { if (stat(path, &statbuf) != -1) { if (S_ISDIR(statbuf.st_mode)) { - list_files_recursively(path, head); + if (max_depth == -1 || current_depth < max_depth) { + list_files_recursively(path, head, max_depth, current_depth + 1); + } } else if (S_ISREG(statbuf.st_mode)) { add_file_path(head, path); } |
