summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorAbdellah El Morabit <nsrddyn@gmail.com>2025-02-22 22:47:45 +0100
committerAbdellah El Morabit <nsrddyn@gmail.com>2025-02-22 22:47:45 +0100
commit72e9194b258e30883b7b13c2385a01fdbb07656d (patch)
tree7677c0a5adc8e29cbe0da5141b0788ffc5b11fff /main.c
parent7c8463b343d76949775480faa2b343264f805e84 (diff)
worked on the other features still encountering a lot of small problems and other discoveries but getting their, the program is almost finished
Diffstat (limited to 'main.c')
-rw-r--r--main.c26
1 files changed, 13 insertions, 13 deletions
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) {