void do_sort (dir_list * list, sortfn * sort, int top, gboolean reverse_f, gboolean case_sensitive_f, gboolean exec_first_f) { int dot_dot_found = 0; if (top == 0) return; /* If there is an ".." entry the caller must take care to ensure that it occupies the first list element. */ if (strcmp (list->list[0].fname, "..") == 0) dot_dot_found = 1; reverse = reverse_f ? -1 : 1; case_sensitive = case_sensitive_f ? 1 : 0; exec_first = exec_first_f; qsort (&(list->list)[dot_dot_found], top + 1 - dot_dot_found, sizeof (file_entry), sort); clean_sort_keys (list, dot_dot_found, top + 1 - dot_dot_found); }
void dir_list_sort (dir_list * list, GCompareFunc sort, const dir_sort_options_t * sort_op) { file_entry_t *fentry; int dot_dot_found = 0; if (list->len < 2 || sort == (GCompareFunc) unsorted) return; /* If there is an ".." entry the caller must take care to ensure that it occupies the first list element. */ fentry = &list->list[0]; if (DIR_IS_DOTDOT (fentry->fname)) dot_dot_found = 1; reverse = sort_op->reverse ? -1 : 1; case_sensitive = sort_op->case_sensitive ? 1 : 0; exec_first = sort_op->exec_first; qsort (&(list->list)[dot_dot_found], list->len - dot_dot_found, sizeof (file_entry_t), sort); clean_sort_keys (list, dot_dot_found, list->len - dot_dot_found); }