summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdellah El Morabit <nsrddyn@gmail.com>2025-02-25 20:19:11 +0100
committerAbdellah El Morabit <nsrddyn@gmail.com>2025-02-25 20:19:11 +0100
commit701d5651632e17d03b8cd81d85a56099ff1a2445 (patch)
tree7baebf4668878eb45696fa218907b1e4e74c0ebc
parenta9a967642be399d21211519751e9a84b217fcd1d (diff)
added the make file feature
-rwxr-xr-xa.outbin51736 -> 51784 bytes
-rw-r--r--folder/anotherfile0
-rw-r--r--folder/newfile.txt0
-rw-r--r--main.c13
4 files changed, 13 insertions, 0 deletions
diff --git a/a.out b/a.out
index 0ec461a..9627aa6 100755
--- a/a.out
+++ b/a.out
Binary files differ
diff --git a/folder/anotherfile b/folder/anotherfile
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/folder/anotherfile
diff --git a/folder/newfile.txt b/folder/newfile.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/folder/newfile.txt
diff --git a/main.c b/main.c
index 2b2e599..e317df4 100644
--- a/main.c
+++ b/main.c
@@ -56,6 +56,8 @@ void change_directory(const char *path);
void change_ownership(const char *path);
+void make_file(const char *path);
+
void clear(const char *arg);
void echo(const char *arg);
@@ -73,6 +75,7 @@ struct exec_command CommandsList[] = {
{"pwd", print_cdirectory},
{"cd", change_directory},
{"clr", clear},
+ {"mkfile", make_file},
{"echo", echo},
{"exit", exit_}
};
@@ -190,6 +193,16 @@ void remove_file(const char *path) {
}
}
+void make_file(const char *path)
+{
+
+ FILE *new_file = fopen(path, "w");
+ if (new_file == NULL)
+ {
+ perror("failed to create the new file");
+ }
+}
+
void change_ownership(const char *path) {
if (chmod(path,S_IRWXU) != 0) {
perror("failed to get ownership of the file");