Changeset 0296ee1 in mainline
- Timestamp:
- 2018-12-08T14:50:11Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 41453d93
- Parents:
- a27e370
- git-author:
- Matthieu Riolo <matthieu.riolo@…> (2018-12-08 14:22:17)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2018-12-08 14:50:11)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/ls/ls.c
ra27e370 r0296ee1 59 59 { "unsort", no_argument, 0, 'u' }, 60 60 { "recursive", no_argument, 0, 'r' }, 61 { " well-formatted", no_argument, 0, 'w' },61 { "exact-size", no_argument, 0, 'e' }, 62 62 { "single-column", no_argument, 0, '1' }, 63 63 { 0, 0, 0, 0 } … … 79 79 ls->sort = 1; 80 80 81 ls->well_formatted = false;81 ls->well_formatted = true; 82 82 ls->single_column = false; 83 83 ls->printer = ls_print; … … 98 98 static void ls_print(struct dir_elem_t *de) 99 99 { 100 int width = 13; 100 101 101 102 if (de->s.is_file) { … … 108 109 char *rptr; 109 110 if (cap_format(&cap, &rptr) == EOK) { 110 printf("%-40s\t%s\n", de->name, rptr); 111 char bytes[9], suffix[3]; 112 sscanf(rptr, "%s %s", bytes, suffix); 111 113 free(rptr); 114 115 printf("%-40s\t%*s %2s\n", de->name, width - 3, bytes, suffix); 116 112 117 //if there is a failure with cap_format we simply print out an unformatted size 113 118 return; … … 116 121 } 117 122 118 printf("%-40s\t% llu\n", de->name, (long long) de->s.size);123 printf("%-40s\t%*llu\n", de->name, width, (long long) de->s.size); 119 124 } else if (de->s.is_directory) 120 printf("%-40s\t <dir>\n", de->name);125 printf("%-40s\t%*s\n", de->name, width, "<dir>"); 121 126 else 122 127 printf("%-40s\n", de->name); … … 387 392 " -u, --unsort Do not sort directory entries\n" 388 393 " -r, --recursive List subdirectories recursively\n" 389 " - w, --well-formatted File sizes will be formatted\n"394 " -e, --exact-size File sizes will be unformatted (raw bytes count)\n" 390 395 " -1, --single-column Only the names will be returned\n", 391 396 cmdname); … … 417 422 418 423 while (c != -1) { 419 c = getopt_long(argc, argv, "hur w1", long_options, &opt_ind);424 c = getopt_long(argc, argv, "hure1", long_options, &opt_ind); 420 425 switch (c) { 421 426 case 'h': … … 428 433 ls.recursive = 1; 429 434 break; 430 case ' w':431 ls.well_formatted = true;435 case 'e': 436 ls.well_formatted = false; 432 437 break; 433 438 case '1':
Note:
See TracChangeset
for help on using the changeset viewer.