From 7c8463b343d76949775480faa2b343264f805e84 Mon Sep 17 00:00:00 2001 From: Abdellah El Morabit Date: Sat, 22 Feb 2025 22:46:47 +0100 Subject: working on the recursive deletion of a folder --- main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 63b1e3d..da3d895 100644 --- a/main.c +++ b/main.c @@ -149,9 +149,17 @@ void remove_dir(const char *path) struct dirent *entry; DIR *dP = opendir(path); - if (dP == NULL){ - perror("failed to open the directory to delete the files recursivly"); + if (dP == NULL) { + perror("failed to open the directory to delete the files recursively"); } + + // ReSharper disable once CppPointerConversionDropsQualifiers + while ((entry = readdir(dP)) != NULL) { + if (rmdir(entry->d_name) != 0) { + perror("failed to delete the directory 02"); + } + } + printf("%p", dP); } } -- cgit v1.2.3-70-g09d2