games and themes sorting
This commit is contained in:
parent
e0e741ac24
commit
74a63e13c1
|
@ -97,6 +97,18 @@ err:
|
||||||
return strdup(d_name);
|
return strdup(d_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cmp_game(const void *p1, const void *p2)
|
||||||
|
{
|
||||||
|
const struct game *g1 = (const struct game*)p1;
|
||||||
|
const struct game *g2 = (const struct game*)p2;
|
||||||
|
return strcmp(g1->name, g2->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void games_sort()
|
||||||
|
{
|
||||||
|
qsort(games, games_nr, sizeof(struct game), cmp_game);
|
||||||
|
}
|
||||||
|
|
||||||
int games_lookup(const char *path)
|
int games_lookup(const char *path)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -136,6 +148,7 @@ int games_lookup(const char *path)
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
closedir(d);
|
closedir(d);
|
||||||
|
games_sort();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -475,6 +475,18 @@ err:
|
||||||
return strdup(d_name);
|
return strdup(d_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cmp_theme(const void *p1, const void *p2)
|
||||||
|
{
|
||||||
|
const struct theme *t1 = (const struct theme*)p1;
|
||||||
|
const struct theme *t2 = (const struct theme*)p2;
|
||||||
|
return strcmp(t1->name, t2->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void themes_sort()
|
||||||
|
{
|
||||||
|
qsort(themes, themes_nr, sizeof(struct theme), cmp_theme);
|
||||||
|
}
|
||||||
|
|
||||||
int themes_lookup(const char *path)
|
int themes_lookup(const char *path)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -512,6 +524,7 @@ int themes_lookup(const char *path)
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
closedir(d);
|
closedir(d);
|
||||||
|
themes_sort();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue