ls Recurse add
This commit is contained in:
parent
ac241ac079
commit
0b60688f6a
2
TODO
2
TODO
|
@ -1,7 +1,7 @@
|
|||
With "micro-" prefix
|
||||
|
||||
*Todo:
|
||||
**ls (file)
|
||||
**ls (file, indicator, GetPerm and print)
|
||||
tail
|
||||
expr
|
||||
uniq
|
||||
|
|
|
@ -19,6 +19,7 @@ unsigned int a_flag;
|
|||
unsigned int l_flag;
|
||||
unsigned int F_flag;
|
||||
unsigned int c_flag;
|
||||
unsigned int R_flag;
|
||||
unsigned int p_flag;
|
||||
|
||||
struct d_node {
|
||||
|
@ -232,7 +233,7 @@ int ls(const char *dir_name, int label, struct winsize w) {
|
|||
if (dir == NULL)
|
||||
return 1;
|
||||
|
||||
if (label)
|
||||
if (label || R_flag)
|
||||
printf("\n%s:\n", dir_name);
|
||||
|
||||
/* pipe print */
|
||||
|
@ -247,13 +248,18 @@ int ls(const char *dir_name, int label, struct winsize w) {
|
|||
else
|
||||
col_print(dir, files, w);
|
||||
|
||||
if (R_flag)
|
||||
for (size_t i = 0; i < files; i++)
|
||||
if (S_ISDIR(dir[i]->stats.st_mode))
|
||||
ls(dir[i]->name, 1, w);
|
||||
|
||||
dfree(dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "alFc")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "alFcR")) != -1) {
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
a_flag = 1;
|
||||
|
@ -271,8 +277,12 @@ int main(int argc, char **argv) {
|
|||
c_flag = 1;
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
R_flag = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("ls [dir1 dir2...]\n\t[-a Show hidden files]\n\t[-l Use a long listing format]\n\t[-F Append indicator to names]\n\t[-c color mode]\n");
|
||||
printf("ls [dir1 dir2...]\n\t[-a Show hidden files]\n\t[-l Use a long listing format]\n\t[-F Append indicator to names]\n\t[-c Color mode] [-R Recursive]\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue