sort DOL files by name
This commit is contained in:
+7
-4
@@ -30,9 +30,14 @@ DOLFileIndex::DOLFileIndex(const string& directory) {
|
|||||||
this->menu = menu;
|
this->menu = menu;
|
||||||
menu->items.emplace_back(ProgramsMenuItemID::GO_BACK, "Go back", "Return to the\nmain menu", 0);
|
menu->items.emplace_back(ProgramsMenuItemID::GO_BACK, "Go back", "Return to the\nmain menu", 0);
|
||||||
|
|
||||||
uint32_t next_menu_item_id = 0;
|
std::vector<std::string> filenames;
|
||||||
for (const auto& item : std::filesystem::directory_iterator(directory)) {
|
for (const auto& item : std::filesystem::directory_iterator(directory)) {
|
||||||
string filename = item.path().filename().string();
|
filenames.emplace_back(item.path().filename().string());
|
||||||
|
}
|
||||||
|
std::sort(filenames.begin(), filenames.end());
|
||||||
|
|
||||||
|
uint32_t next_menu_item_id = 0;
|
||||||
|
for (const auto& filename : filenames) {
|
||||||
bool is_dol = filename.ends_with(".dol");
|
bool is_dol = filename.ends_with(".dol");
|
||||||
bool is_compressed_dol = filename.ends_with(".dol.prs");
|
bool is_compressed_dol = filename.ends_with(".dol.prs");
|
||||||
if (!is_dol && !is_compressed_dol) {
|
if (!is_dol && !is_compressed_dol) {
|
||||||
@@ -82,9 +87,7 @@ DOLFileIndex::DOLFileIndex(const string& directory) {
|
|||||||
description = std::format("$C6{}$C7\n{}", dol->name, size_str);
|
description = std::format("$C6{}$C7\n{}", dol->name, size_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->name_to_file.emplace(dol->name, dol);
|
|
||||||
this->item_id_to_file.emplace_back(dol);
|
this->item_id_to_file.emplace_back(dol);
|
||||||
|
|
||||||
menu->items.emplace_back(dol->menu_item_id, dol->name, description, MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL_RUNS_CODE);
|
menu->items.emplace_back(dol->menu_item_id, dol->name, description, MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL_RUNS_CODE);
|
||||||
|
|
||||||
} catch (const exception& e) {
|
} catch (const exception& e) {
|
||||||
|
|||||||
+1
-2
@@ -20,13 +20,12 @@ struct DOLFileIndex {
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::vector<std::shared_ptr<File>> item_id_to_file;
|
std::vector<std::shared_ptr<File>> item_id_to_file;
|
||||||
std::unordered_map<std::string, std::shared_ptr<File>> name_to_file;
|
|
||||||
std::shared_ptr<const Menu> menu;
|
std::shared_ptr<const Menu> menu;
|
||||||
|
|
||||||
DOLFileIndex() = default;
|
DOLFileIndex() = default;
|
||||||
explicit DOLFileIndex(const std::string& directory);
|
explicit DOLFileIndex(const std::string& directory);
|
||||||
|
|
||||||
inline bool empty() const {
|
inline bool empty() const {
|
||||||
return this->name_to_file.empty() && this->item_id_to_file.empty();
|
return this->item_id_to_file.empty();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user