1
0
Fork 0
mirror of https://github.com/pygos/pkg-utils.git synced 2024-11-24 21:40:43 +01:00

make file list sorting more robust

If entries are sorted by length and some have the same length, sort
them asciibetically.

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
This commit is contained in:
David Oberhollenzer 2019-04-17 16:27:39 +02:00
parent eadeee25d9
commit cd79a4fccf

View file

@ -6,6 +6,8 @@
static int compare_ent(image_entry_t *a, image_entry_t *b)
{
int diff;
/* directories < .. < symlinks < devices < .. < files */
switch (a->mode & S_IFMT) {
case S_IFDIR:
@ -31,7 +33,8 @@ static int compare_ent(image_entry_t *a, image_entry_t *b)
return -1;
}
out_len:
return (int)strlen(a->name) - (int)strlen(b->name);
diff = (int)strlen(a->name) - (int)strlen(b->name);
return diff ? diff : strcmp(a->name, b->name);
out_fsize:
if (a->data.file.size > b->data.file.size)
return 1;