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 --- cmake-build-debug/Testing/Temporary/LastTest.log | 4 ++-- main.c | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmake-build-debug/Testing/Temporary/LastTest.log b/cmake-build-debug/Testing/Temporary/LastTest.log index 56213aa..225e1e8 100644 --- a/cmake-build-debug/Testing/Temporary/LastTest.log +++ b/cmake-build-debug/Testing/Temporary/LastTest.log @@ -1,3 +1,3 @@ -Start testing: Feb 22 21:47 CET +Start testing: Feb 23 12:12 CET ---------------------------------------------------------- -End testing: Feb 22 21:47 CET +End testing: Feb 23 12:12 CET 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