Added 'cd' and 'dir' command
This commit is contained in:
parent
5479b61dbf
commit
c80f6617c3
7 changed files with 112 additions and 10 deletions
20
commands/change_dir.c
Normal file
20
commands/change_dir.c
Normal 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);
|
||||
}
|
||||
Reference in a new issue