summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorAbdellah El Morabit <nsrddyn@gmail.com>2025-02-23 21:31:27 +0100
committerAbdellah El Morabit <nsrddyn@gmail.com>2025-02-23 21:31:27 +0100
commitc887a71add3ebb8ed5bf1436c2746651b1e7b640 (patch)
treeebff1cc84ad926f6764264380ba8e83f7839873d /main.c
parent72e9194b258e30883b7b13c2385a01fdbb07656d (diff)
worked on the looping over the files / entries in a directory
Diffstat (limited to 'main.c')
-rw-r--r--main.c8
1 files changed, 5 insertions, 3 deletions
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");
}