Changeset a20a451 in mainline
- Timestamp:
- 2018-11-30T09:40:48Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 87ba3ceb
- Parents:
- c483fca
- Location:
- uspace/app/bdsh/cmds/modules/ls
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/ls/ls.c
rc483fca ra20a451 42 42 #include <vfs/vfs.h> 43 43 #include <str.h> 44 #include <cap.h> 44 45 45 46 #include "ls.h" … … 58 59 { "unsort", no_argument, 0, 'u' }, 59 60 { "recursive", no_argument, 0, 'r' }, 61 { "well-formatted", no_argument, 0, 'w' }, 62 { "single-column", no_argument, 0, '1' }, 60 63 { 0, 0, 0, 0 } 61 64 }; … … 74 77 ls->sort = 1; 75 78 79 ls->well_formatted = false; 80 ls->single_column = false; 81 76 82 return 1; 77 83 } … … 90 96 static void ls_print(struct dir_elem_t *de) 91 97 { 92 if (de->s.is_file) 98 if (!ls.single_column && de->s.is_file) { 99 if (ls.well_formatted) { 100 cap_spec_t cap; 101 102 cap_from_blocks(1, de->s.size, &cap); 103 cap_simplify(&cap); 104 105 char *rptr; 106 if (cap_format(&cap, &rptr) == EOK) { 107 printf("%-40s\t%s\n", de->name, rptr); 108 free(rptr); 109 //if there is a failure with cap_format we simply print out an unformatted size 110 return; 111 } 112 113 } 114 93 115 printf("%-40s\t%llu\n", de->name, (long long) de->s.size); 94 else if (de->s.is_directory)116 } else if (!ls.single_column && de->s.is_directory) 95 117 printf("%-40s\t<dir>\n", de->name); 96 118 else … … 364 386 365 387 while (c != -1) { 366 c = getopt_long(argc, argv, "hur ", long_options, &opt_ind);388 c = getopt_long(argc, argv, "hurw1", long_options, &opt_ind); 367 389 switch (c) { 368 390 case 'h': … … 374 396 case 'r': 375 397 ls.recursive = 1; 398 break; 399 case 'w': 400 ls.well_formatted = true; 401 break; 402 case '1': 403 ls.single_column = true; 376 404 break; 377 405 } -
uspace/app/bdsh/cmds/modules/ls/ls.h
rc483fca ra20a451 14 14 unsigned int sort; 15 15 16 bool single_column; 17 bool well_formatted; 16 18 } ls_job_t; 17 19
Note:
See TracChangeset
for help on using the changeset viewer.