From 72e9194b258e30883b7b13c2385a01fdbb07656d Mon Sep 17 00:00:00 2001 From: Abdellah El Morabit Date: Sat, 22 Feb 2025 22:47:45 +0100 Subject: worked on the other features still encountering a lot of small problems and other discoveries but getting their, the program is almost finished --- main.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index da3d895..79117fa 100644 --- a/main.c +++ b/main.c @@ -31,6 +31,8 @@ struct command split_command(char *input); void exec_command(char *input); +void split_arg(struct command argument); + // shell commands functions prototypes void list(const char *path); @@ -38,11 +40,11 @@ void make_dir(const char *path); void remove_file(const char *path); -void remove_dir(const char *path); // trying to delete the folder and the files init recursivly +void remove_dir(const char *path); // trying to delete the folder and the files init recursively -void copy_files(const char *arg); +void copy_files(struct split_arg); -void move_files(const char *arg); +void move_files(struct split_arg); void print_cdirectory(const char *arg); @@ -129,7 +131,7 @@ void list(const char *path) { // check if the directory got opened successfully if (dP == NULL) { - perror("opendir"); + perror("failed to open directory"); return; } @@ -140,14 +142,12 @@ void list(const char *path) { closedir(dP); } -void remove_dir(const char *path) -{ - if (rmdir(path) != 0){ +void remove_dir(const char *path) { + if (rmdir(path) != 0) { perror("failed to delete the directory"); - } - else if { + } else { struct dirent *entry; - DIR *dP = opendir(path); + const DIR *dP = opendir(path); if (dP == NULL) { perror("failed to open the directory to delete the files recursively"); @@ -176,14 +176,14 @@ void remove_file(const char *path) { } void change_ownership(const char *path) { - if ((chmod(path,S_IRWXU) != 0)) { + if (chmod(path,S_IRWXU) != 0) { perror("failed to get ownership of the file"); } else { printf("file permissions updated successfully"); } } -void copy_files(const char *arg) { +void copy_files(const struct split_arg argument) { // split the argument into the source and destination // make a copy of the source file in the destination file int c; @@ -225,7 +225,7 @@ void clear(const char *arg) { } void echo(const char *arg) { - printf("%s", arg); + printf("%s\n", arg); } void exit_(const char *arg) { -- cgit v1.2.3-70-g09d2