Ignore:
File:
1 edited

Legend:

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

    rf2460a50 r8d2dd7f2  
    3939#include <vfs/vfs.h>
    4040#include <str.h>
     41#include <sort.h>
    4142
    4243#include "ls.h"
     
    6162static unsigned int ls_start(ls_job_t *);
    6263static void ls_print(struct dir_elem_t *);
    63 static int ls_cmp(const void *, const void *);
     64static int ls_cmp(void *, void *, void *);
    6465static signed int ls_scan_dir(const char *, DIR *, struct dir_elem_t **);
    6566static unsigned int ls_recursive(const char *, DIR *);
     
    103104 * @param a             Pointer to the structure of the first element.
    104105 * @param b             Pointer to the structure of the second element.
     106 * @param arg           Pointer for an other and optionnal argument.
    105107 *
    106108 * @return              -1 if a < b, 1 otherwise.
    107109 */
    108 static int ls_cmp(const void *a, const void *b)
    109 {
    110         struct dir_elem_t const *da = a;
    111         struct dir_elem_t const *db = b;
     110static int ls_cmp(void *a, void *b, void *arg)
     111{
     112        struct dir_elem_t *da = a;
     113        struct dir_elem_t *db = b;
    112114       
    113115        if ((da->s.is_directory && db->s.is_file) ||
     
    189191        }
    190192       
    191         if (ls.sort)
    192                 qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t), ls_cmp);
     193        if (ls.sort) {
     194                if (!qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t),
     195                    ls_cmp, NULL)) {
     196                        printf("Sorting error.\n");
     197                }
     198        }
    193199       
    194200        for (i = 0; i < nbdirs; i++)
Note: See TracChangeset for help on using the changeset viewer.