Ignore:
Timestamp:
Jul 24, 2015, 3:10:49 PM (9 years ago)
Author:
guerin
Message:

shell: use readdir for ls

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/applications/shell/main.c

    r655 r660  
    4848static void cmd_ls(int argc, char** argv)
    4949{
    50     if (argc < 2)
    51     {
    52         giet_tty_printf("%s <path>\n", argv[0]);
    53         return;
    54     }
    55 
    56     giet_fat_list(argv[1]);
     50    int fd;
     51    fat_dirent_t entry;
     52
     53    if (argc < 2)
     54        fd = giet_fat_opendir("/");
     55    else
     56        fd = giet_fat_opendir(argv[1]);
     57
     58    if (fd < 0)
     59    {
     60        giet_tty_printf("can't list directory (err=%d)\n", fd);
     61        return;
     62    }
     63
     64    while (giet_fat_readdir(fd, &entry) == 0)
     65    {
     66        if (entry.is_dir)
     67            giet_tty_printf("dir ");
     68        else
     69            giet_tty_printf("file");
     70
     71        giet_tty_printf(" | size = %d \t| cluster = %X \t| %s\n",
     72                        entry.size, entry.cluster, entry.name );
     73    }
     74
     75    giet_fat_closedir(fd);
    5776}
    5877
     
    85104    int src_fd = -1;
    86105    int dst_fd = -1;
    87     struct fat_file_info_s info;
     106    fat_file_info_t info;
    88107    int size;
    89108    int i;
Note: See TracChangeset for help on using the changeset viewer.