Added 'cd' and 'dir' command

This commit is contained in:
netbenixcn 2020-06-07 11:16:25 +02:00
parent 5479b61dbf
commit c80f6617c3
7 changed files with 112 additions and 10 deletions

20
commands/change_dir.c Normal file
View file

@ -0,0 +1,20 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
#include "change_dir.h"
#include "../utils/logger.h"
void changeCurrentWorkDir(char *arg[]){
DIR *d;
struct dirent *dir;
d = opendir(arg[1]);
if(d == NULL){
printf("Folder not found.\n");
return;
} else {
chdir(arg[1]);
}
closedir(d);
}