From d6d9cb137d1f0f75fd68381ec699f76b518061d5 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Wed, 21 Jan 2026 22:43:38 +0100 Subject: Enable single file processing --- list.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'list.c') diff --git a/list.c b/list.c index 8c5b478..e1d4ffd 100644 --- a/list.c +++ b/list.c @@ -23,6 +23,17 @@ void add_file_path(Node **head, char *file_path) { } void list_files_recursively(char *base_path, Node **head) { + struct stat statbuf; + if (stat(base_path, &statbuf) == -1) { + perror("stat"); + return; + } + + if (S_ISREG(statbuf.st_mode)) { + add_file_path(head, base_path); + return; + } + char path[2048]; struct dirent *dp; DIR *dir = opendir(base_path); @@ -39,11 +50,10 @@ void list_files_recursively(char *base_path, Node **head) { continue; } - struct stat statbuf; if (stat(path, &statbuf) != -1) { if (S_ISDIR(statbuf.st_mode)) { list_files_recursively(path, head); - } else { + } else if (S_ISREG(statbuf.st_mode)) { add_file_path(head, path); } } -- cgit v1.2.3