From c887a71add3ebb8ed5bf1436c2746651b1e7b640 Mon Sep 17 00:00:00 2001 From: Abdellah El Morabit Date: Sun, 23 Feb 2025 21:31:27 +0100 Subject: worked on the looping over the files / entries in a directory --- main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 79117fa..dcad1f2 100644 --- a/main.c +++ b/main.c @@ -42,9 +42,9 @@ void remove_file(const char *path); void remove_dir(const char *path); // trying to delete the folder and the files init recursively -void copy_files(struct split_arg); +void copy_files(struct split_arg argument); -void move_files(struct split_arg); +void move_files(struct split_arg argument); void print_cdirectory(const char *arg); @@ -115,6 +115,7 @@ void exec_command(char *input) { for (int i = 0; i < sizeof(CommandsList) / sizeof(CommandsList[0]); i++) { if (strcmp(user_command.com, CommandsList[i].cmd) == 0) { CommandsList[i].func(user_command.arg); + break; } } free(user_command.com); @@ -154,7 +155,8 @@ void remove_dir(const char *path) { } // ReSharper disable once CppPointerConversionDropsQualifiers - while ((entry = readdir(dP)) != NULL) { + while ((entry = readdir(dP)) != NULL && (strcmp(entry->d_name, ".") != 0) && ( + strcmp(entry->d_name, "..") != 0)) { if (rmdir(entry->d_name) != 0) { perror("failed to delete the directory 02"); } -- cgit v1.2.3-70-g09d2