Mercurial > repos > blastem
comparison menu.c @ 1484:d82af64c94d2 nuklear_ui
Sort directory listing in Nuklear UI file browser
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 26 Nov 2017 17:33:39 -0800 |
parents | 77a401044935 |
children | 369da70ee2c2 |
comparison
equal
deleted
inserted
replaced
1483:001120e91fed | 1484:d82af64c94d2 |
---|---|
37 //meaning either the request is complete or no request is pending | 37 //meaning either the request is complete or no request is pending |
38 //in the current implementation, the operations happen instantly | 38 //in the current implementation, the operations happen instantly |
39 //in emulated time so we can always return 0 | 39 //in emulated time so we can always return 0 |
40 return 0; | 40 return 0; |
41 } | 41 } |
42 } | |
43 | |
44 int menu_dir_sort(const void *a, const void *b) | |
45 { | |
46 const dir_entry *da, *db; | |
47 da = a; | |
48 db = b; | |
49 if (da->is_dir != db->is_dir) { | |
50 return db->is_dir - da->is_dir; | |
51 } | |
52 return strcasecmp(((dir_entry *)a)->name, ((dir_entry *)b)->name); | |
53 } | 42 } |
54 | 43 |
55 void copy_string_from_guest(m68k_context *m68k, uint32_t guest_addr, char *buf, size_t maxchars) | 44 void copy_string_from_guest(m68k_context *m68k, uint32_t guest_addr, char *buf, size_t maxchars) |
56 { | 45 { |
57 char *cur; | 46 char *cur; |
161 } | 150 } |
162 #endif | 151 #endif |
163 size_t num_entries; | 152 size_t num_entries; |
164 dir_entry *entries = get_dir_list(menu->curpath, &num_entries); | 153 dir_entry *entries = get_dir_list(menu->curpath, &num_entries); |
165 if (entries) { | 154 if (entries) { |
166 qsort(entries, num_entries, sizeof(dir_entry), menu_dir_sort); | 155 sort_dir_list(entries, num_entries); |
167 } else { | 156 } else { |
168 warning("Failed to open directory %s: %s\n", menu->curpath, strerror(errno)); | 157 warning("Failed to open directory %s: %s\n", menu->curpath, strerror(errno)); |
169 entries = malloc(sizeof(dir_entry)); | 158 entries = malloc(sizeof(dir_entry)); |
170 entries->name = strdup(".."); | 159 entries->name = strdup(".."); |
171 entries->is_dir = 1; | 160 entries->is_dir = 1; |