mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-04 14:37:46 -04:00
add .. to dir listing if it is missing
This commit is contained in:
parent
ff8abdddba
commit
d23f5773e1
1 changed files with 11 additions and 1 deletions
12
menu.c
12
menu.c
|
@ -475,7 +475,7 @@ static int me_id2offset(const menu_entry *ent, menu_id id)
|
|||
static void me_enable(menu_entry *entries, menu_id id, int enable)
|
||||
{
|
||||
int i = me_id2offset(entries, id);
|
||||
entries[i].enabled = enable;
|
||||
entries[i].enabled = !!enable;
|
||||
}
|
||||
|
||||
static int me_count(const menu_entry *ent)
|
||||
|
@ -1076,6 +1076,16 @@ rescan:
|
|||
if (n > 1)
|
||||
qsort(namelist, n, sizeof(namelist[0]), scandir_cmp);
|
||||
|
||||
// add ".." if it's somehow not there
|
||||
if (n == 0 || strcmp(namelist[0]->d_name, "..")) {
|
||||
struct dirent *dotdot = malloc(sizeof(*dotdot));
|
||||
*dotdot = (struct dirent) { .d_name="..", .d_type=DT_DIR };
|
||||
namelist = realloc(namelist, (n+1)*sizeof(*namelist));
|
||||
memmove(namelist+1, namelist, n*sizeof(*namelist));
|
||||
namelist[0] = dotdot;
|
||||
n++;
|
||||
}
|
||||
|
||||
// try to find selected file
|
||||
sel = 0;
|
||||
if (sel_fname[0] != 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue