-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrom_browser.cpp
More file actions
38 lines (30 loc) · 809 Bytes
/
Copy pathrom_browser.cpp
File metadata and controls
38 lines (30 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "rom_browser.h"
#include <filesystem>
#include <algorithm>
std::vector<RomEntry> LoadRoms(const std::string& romFolder)
{
std::vector<RomEntry> roms;
if (!std::filesystem::exists(romFolder))
return roms;
for (const auto& entry : std::filesystem::directory_iterator(romFolder))
{
if (!entry.is_regular_file())
continue;
auto path = entry.path();
if (path.extension() == ".bin" || path.extension() == ".BIN")
{
roms.push_back({
path.stem().string(),
path.string()
});
}
}
std::sort(
roms.begin(),
roms.end(),
[](const RomEntry& a, const RomEntry& b)
{
return a.name < b.name;
});
return roms;
}