This commit is contained in:
Jakub Adamski 2019-01-18 21:41:24 +01:00
parent 0e8d433065
commit 0f2b0f2919
5 changed files with 34 additions and 9 deletions

View File

@ -19,7 +19,18 @@ spath:
help - shows help page
0 - turns off displaying current directory
1 - turns on displaying current directory
PATH commands
showtree:
help - shows help page
no argument - shows tree of current directory
one argument - shows tree of directory in argument
showps:
help - shows help page
prints all process names ond pids
mycp:
help - shows help page
with 2 arguments - copyies file from first argument to
file in second argument
PATH commands:
if you want colors use
for example ls --color

View File

@ -1,2 +0,0 @@
To jest plik1.txt
jajajajaj

View File

@ -1 +0,0 @@
testtt

Binary file not shown.

View File

@ -87,7 +87,7 @@ void help (char **argv){
void exe (char **argv){
if (fork() == 0){
execvp(argv[0], argv);
perror("execvp");
perror("Comand execution error");
exit(EXIT_FAILURE);
}
else
@ -102,7 +102,7 @@ void ptab (int ile){
void tree (char **argv, char * directory){
if (argv[1] != NULL && argv[2] != NULL){
printf("Too many arguments\nshowtree takes no arguments \nor exacly 1 argument for desired directory\n");
printf("Too many arguments\n");
return;
}
else{
@ -113,12 +113,16 @@ void tree (char **argv, char * directory){
int tab = 0;
if (argv[1] != NULL && argv[2] == NULL){ /*jeden argument*/
if (!strcmp(argv[1], "help")){
printf("Showtree prints catalog and file structure\ntakes no arguments \nor exacly 1 argument for desired directory\n");
exit(0);
}
cd(argv);
getcwd(ndr, sizeof(ndr));
}
else
strcpy(ndr, directory);
printf("Content of: %s\n", ndr);
printf("Content of: %s\n\n", ndr);
if ((d = opendir(ndr)) != NULL){ /*wchodzimy do katalogu*/
while ((ent = readdir(d)) != NULL){ /*czytamy zawartosc*/
@ -156,11 +160,16 @@ void tree (char **argv, char * directory){
void mycp (char **argv){
if (argv[1] == NULL || argv[2] == NULL){
printf("Add arguments\n");
if(argv[1] != NULL && argv[2] == NULL)
if (!strcmp(argv[1], "help")){
printf("Needs exacly 2 arguments\ncopyies file from first argument to file in second argument\n");
return;
}
printf("Add arguments\nfor more info type 'mycp help'\n");
return;
}
else if (argv[3] != NULL){
printf("Too many arguments\n");
printf("Too many arguments\nfor more info type 'mycp help'\n");
return;
}
else{
@ -190,6 +199,14 @@ void mycp (char **argv){
}
void myps (char **argv){
if (argv[1] != NULL){
if(!strcmp(argv[1], "help")){
printf("Showps prints all prosess and pids\ntakes no arguments\n");
}
else
printf("Type 'showps help'\n");
return;
}
if (fork() == 0){
if (chdir("/proc") != 0){
perror("cant open /proc");