showtree wyswietla cala zawartosc
This commit is contained in:
parent
3db7748748
commit
73b9b7d679
0
Microshell/katalog/plik1.txt
Normal file
0
Microshell/katalog/plik1.txt
Normal file
0
Microshell/katalog/test/test.txt
Normal file
0
Microshell/katalog/test/test.txt
Normal file
Binary file not shown.
@ -96,28 +96,30 @@ void tree (char **argv, char * directory){
|
|||||||
if (fork() == 0){
|
if (fork() == 0){
|
||||||
DIR *d;
|
DIR *d;
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
char ndr[max], lastdir[max];
|
char ndr[max];
|
||||||
strcpy(ndr, directory);
|
strcpy(ndr, directory);
|
||||||
|
|
||||||
while(1){
|
if ((d = opendir(ndr)) != NULL){ /*wchodzimy do katalogu*/
|
||||||
strcpy(lastdir, ndr);
|
while ((ent = readdir(d)) != NULL){ /*czytamy zawartosc*/
|
||||||
if ((d = opendir(ndr)) != NULL){ /*wchodzimy do katalogu*/
|
char *name = ent->d_name;
|
||||||
while ((ent = readdir(d)) != NULL){ /*czytamy zawartosc*/
|
if (!(!strcmp(name, ".") || !strcmp(name, ".."))){ /*jesli nazwa rozna od . lub .. */
|
||||||
char *name = ent->d_name;
|
if (fork()==0){
|
||||||
if (!(!strcmp(name, ".") || !strcmp(name, ".."))){ /*jesli nazwa rozna od . lub .. */
|
|
||||||
if (chdir(name) == 0){ /*udalo nam sie wejsc do katalogu*/
|
if (chdir(name) == 0){ /*udalo nam sie wejsc do katalogu*/
|
||||||
closedir(d);
|
closedir(d);
|
||||||
printf("Katalog: %s\n", name);
|
printf("Katalog: %s\n", name);
|
||||||
getcwd(ndr, sizeof(ndr)); /*zmieniamy directory*/
|
getcwd(ndr, sizeof(ndr)); /*zmieniamy directory*/
|
||||||
break; /*break czytanie poprzedniego katalogu*/
|
d = opendir(ndr);
|
||||||
}
|
}
|
||||||
else
|
else{
|
||||||
printf("Plik: %s\n", name);
|
printf("Plik: %s\n", name);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
wait(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!strcmp(lastdir, ndr))
|
closedir(d);
|
||||||
break; /*jezeli nie zmienilismy kat to wychodzimy zeby nie czytac tego samego jeszcze raz*/
|
|
||||||
}
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user