diff options
| author | Abdellah El Morabit <nsrddyn@gmail.com> | 2025-02-22 22:46:47 +0100 |
|---|---|---|
| committer | Abdellah El Morabit <nsrddyn@gmail.com> | 2025-02-22 22:46:47 +0100 |
| commit | 7c8463b343d76949775480faa2b343264f805e84 (patch) | |
| tree | 2972fd495895155f590a5969ab8bcb982f20c434 | |
| parent | c97a0699cffb4070d2e49cdab7bda6a185140b71 (diff) | |
working on the recursive deletion of a folder
| -rw-r--r-- | main.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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); } } |
