mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2025-12-12 13:28:37 +00:00
fix: ensure directory iteration results are sorted by filename (#858)
This commit is contained in:
parent
940a2018e1
commit
e12d5e0aaf
@ -1103,10 +1103,19 @@ bool load_images_from_dir(const std::string dir,
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<fs::directory_entry> entries;
|
||||
for (const auto& entry : fs::directory_iterator(dir)) {
|
||||
if (!entry.is_regular_file())
|
||||
continue;
|
||||
if (entry.is_regular_file()) {
|
||||
entries.push_back(entry);
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(entries.begin(), entries.end(),
|
||||
[](const fs::directory_entry& a, const fs::directory_entry& b) {
|
||||
return a.path().filename().string() < b.path().filename().string();
|
||||
});
|
||||
|
||||
for (const auto& entry : entries) {
|
||||
std::string path = entry.path().string();
|
||||
std::string ext = entry.path().extension().string();
|
||||
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user