Roms list properly handle sorting + use ircolib's log so i can stop worrying about re-definition of macros and shit

This commit is contained in:
2026-06-15 17:06:15 +02:00
parent 642fc17391
commit cf0378719c
53 changed files with 3131 additions and 3079 deletions
+37 -36
View File
@@ -4,55 +4,56 @@
namespace Util {
std::vector<u8> OpenROM(const std::string &filename, size_t &sizeAdjusted) {
auto buf = ircolib::ReadFileBinary(filename);
sizeAdjusted = ircolib::NextPow2(buf.size());
return buf;
auto buf = ircolib::read_file_binary(filename);
sizeAdjusted = ircolib::next_pow2(buf.size());
return buf;
}
std::vector<u8> OpenArchive(const std::string &path, size_t &sizeAdjusted) {
const auto stream = ar_open_file(fs::path(path).string().c_str());
const auto stream = ar_open_file(fs::path(path).string().c_str());
if (!stream) {
panic("Could not open archive! Are you sure it's an archive?");
}
if (!stream) {
ircolib::panic("Could not open archive! Are you sure it's an archive?");
}
ar_archive *archive = ar_open_zip_archive(stream, false);
ar_archive *archive = ar_open_zip_archive(stream, false);
if (!archive)
archive = ar_open_rar_archive(stream);
if (!archive)
archive = ar_open_7z_archive(stream);
if (!archive)
archive = ar_open_tar_archive(stream);
if (!archive)
archive = ar_open_rar_archive(stream);
if (!archive)
archive = ar_open_7z_archive(stream);
if (!archive)
archive = ar_open_tar_archive(stream);
if (!archive) {
ar_close(stream);
panic("Could not open archive! Are you sure it's a supported archive? (7z, zip, rar and tar are supported)");
}
if (!archive) {
ar_close(stream);
ircolib::panic(
"Could not open archive! Are you sure it's a supported archive? (7z, zip, rar and tar are supported)");
}
std::vector<u8> buf{};
std::vector<u8> buf{};
std::vector<std::string> rom_exts{".n64", ".z64", ".v64", ".N64", ".Z64", ".V64"};
std::vector<std::string> rom_exts{".n64", ".z64", ".v64", ".N64", ".Z64", ".V64"};
while (ar_parse_entry(archive)) {
auto filename = ar_entry_get_name(archive);
auto extension = fs::path(filename).extension();
while (ar_parse_entry(archive)) {
auto filename = ar_entry_get_name(archive);
auto extension = fs::path(filename).extension();
if (std::ranges::any_of(rom_exts, [&](const auto &x) { return extension == x; })) {
const auto size = ar_entry_get_size(archive);
sizeAdjusted = ircolib::NextPow2(size);
buf.resize(sizeAdjusted);
ar_entry_uncompress(archive, buf.data(), size);
break;
if (std::ranges::any_of(rom_exts, [&](const auto &x) { return extension == x; })) {
const auto size = ar_entry_get_size(archive);
sizeAdjusted = ircolib::next_pow2(size);
buf.resize(sizeAdjusted);
ar_entry_uncompress(archive, buf.data(), size);
break;
}
ar_close_archive(archive);
ar_close(stream);
ircolib::panic("Could not find any rom image in the archive!");
}
ar_close_archive(archive);
ar_close(stream);
panic("Could not find any rom image in the archive!");
}
ar_close_archive(archive);
ar_close(stream);
return buf;
return buf;
}
}
} // namespace Util