all repos — mgba @ 5578273eb1faaa3614570e29b25d67fa94b5a3ff

mGBA Game Boy Advance Emulator

GUI: Test archives now, too
Jeffrey Pfau jeffrey@endrift.com
Tue, 22 Sep 2015 21:38:58 -0700
commit

5578273eb1faaa3614570e29b25d67fa94b5a3ff

parent

6cf4179a974d6745953d0d354ea8266512d84b83

1 files changed, 35 insertions(+), 20 deletions(-)

jump to
M src/util/gui/file-select.csrc/util/gui/file-select.c

@@ -110,18 +110,42 @@ params->guiFinish();

} params->drawEnd(); } - struct VFile* vf = dir->openFile(dir, GUIMenuItemListGetPointer(currentFiles, item)->title, O_RDONLY); - if (!vf) { + if (!filter) { ++item; continue; } - if (filter && !filter(vf)) { - free(GUIMenuItemListGetPointer(currentFiles, item)->title); - GUIMenuItemListShift(currentFiles, item, 1); - } else { - ++item; + struct VDir* vd = dir->openDir(dir, GUIMenuItemListGetPointer(currentFiles, item)->title); + if (vd) { + bool success = false; + struct VDirEntry* de; + while ((de = vd->listNext(vd)) && !success) { + struct VFile* vf2 = vd->openFile(vd, de->name(de), O_RDONLY); + if (!vf2) { + continue; + } + if (filter(vf2)) { + success = true; + } + vf2->close(vf2); + } + vd->close(vd); + if (success) { + ++item; + continue; + } } - vf->close(vf); + struct VFile* vf = dir->openFile(dir, GUIMenuItemListGetPointer(currentFiles, item)->title, O_RDONLY); + if (vf) { + if (filter(vf)) { + ++item; + } else { + free(GUIMenuItemListGetPointer(currentFiles, item)->title); + GUIMenuItemListShift(currentFiles, item, 1); + } + vf->close(vf); + continue; + } + ++item; } dir->close(dir);

@@ -163,18 +187,9 @@ GUIMenuItemListInit(&newFiles, 0);

if (!_refreshDirectory(params, outPath, &newFiles, filter)) { _cleanFiles(&newFiles); GUIMenuItemListDeinit(&newFiles); - struct VFile* vf = VFileOpen(outPath, O_RDONLY); - if (!vf) { - continue; - } - if (!filter || filter(vf)) { - vf->close(vf); - _cleanFiles(&menu.items); - GUIMenuItemListDeinit(&menu.items); - return true; - } - vf->close(vf); - break; + _cleanFiles(&menu.items); + GUIMenuItemListDeinit(&menu.items); + return true; } else { _cleanFiles(&menu.items); GUIMenuItemListDeinit(&menu.items);