Ignore:
Timestamp:
2009-01-22T15:40:18Z (16 years ago)
Author:
Tim Post <echo@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b7be230
Parents:
4cc0c9ee
Message:

ls now prints file sizes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/ls/ls.c

    r4cc0c9ee rbf226890  
    5050
    5151static char *cmdname = "ls";
     52
     53static inline uint64_t flen(const char *f)
     54{
     55        int fd;
     56        uint64_t size;
     57
     58        fd = open(f, O_RDONLY);
     59        if (fd == -1)
     60                return 0;
     61
     62        size = lseek(fd, 0, SEEK_END);
     63        close(fd);
     64
     65        if (size < 0)
     66                size = 0;
     67
     68        return size;
     69}
    5270
    5371static unsigned int ls_scope(const char *path)
     
    121139static void ls_print_dir(const char *d)
    122140{
    123         printf("%-40s\t<DIR>\n", d);
     141        printf("%-40s\t<dir>\n", d);
    124142
    125143        return;
     
    128146static void ls_print_file(const char *f)
    129147{
    130         printf("%-40s\n", f);
     148        printf("%-40s\t%u\n", f, flen(f));
    131149
    132150        return;
Note: See TracChangeset for help on using the changeset viewer.