android: Build the APK asset tree in the same order its listed in the file.

This tends to get you enumerations in alphabetical order, instead of them
being reverse-alphabetical.

Reference Issue #15587.
This commit is contained in:
Ryan C. Gordon
2026-05-16 15:29:46 -04:00
parent 497b2118ba
commit 5e483dc166

View File

@@ -1875,6 +1875,7 @@ typedef struct APKNode
SDL_PathInfo info;
struct APKNode *parent;
struct APKNode *children;
struct APKNode *children_tail;
struct APKNode *next_sibling;
} APKNode;
@@ -1983,8 +1984,12 @@ static APKNode *AddAPKChildNode(APKNode *parent, const char *child)
SDL_copyp(&node->info, &parent->info); // you probably need to update this afterwards.
node->parent = parent;
node->next_sibling = parent->children;
parent->children = node;
if (parent->children_tail) { // APKs tend to be sorted alphabetically, so insert new nodes at the end of the list to maintain this order.
parent->children_tail->next_sibling = node;
} else {
parent->children = node;
}
parent->children_tail = node;
}
return node;
}