Skip to content

Commit

Permalink
- Return early if device has no directories.
Browse files Browse the repository at this point in the history
- Reduce chance of hanging with an empty recent list.
  • Loading branch information
Extrems committed Dec 19, 2024
1 parent a00e7b5 commit bf92c89
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions cube/swiss/source/devices/memcard/deviceHandler-CARD.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ device_info* deviceHandler_CARD_info(file_handle* file) {
}

s32 deviceHandler_CARD_readDir(file_handle* ffile, file_handle** dir, u32 type){
if(type != -1) return -1;

int num_entries = 1, ret = 0, i = 1, slot = (!strncmp((const char*)initial_CARDB.name, ffile->name, 7));
card_dir *memcard_dir = NULL;
Expand Down
3 changes: 2 additions & 1 deletion cube/swiss/source/devices/qoob/deviceHandler-Qoob.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ u32 sizeToBlocks(u32 size) {
}

s32 deviceHandler_Qoob_readDir(file_handle* ffile, file_handle** dir, u32 type) {

if(type != -1) return -1;

uiDrawObj_t *msgBox = DrawPublish(DrawProgressBar(true, 0, "Reading Qoob"));
// Set everything up to read
int num_entries = 1, i = 1, block = 0;
Expand Down
2 changes: 2 additions & 0 deletions cube/swiss/source/devices/system/deviceHandler-SYS.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ s32 deviceHandler_SYS_init(file_handle* file) {
}

s32 deviceHandler_SYS_readDir(file_handle* ffile, file_handle** dir, u32 type) {
if(type != -1) return -1;

int num_entries = NUM_ROMS, i = ROM_VOID;
*dir = calloc(num_entries, sizeof(file_handle));
concat_path((*dir)[i].name, ffile->name, "..");
Expand Down
1 change: 1 addition & 0 deletions cube/swiss/source/devices/wode/deviceHandler-WODE.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ device_info* deviceHandler_WODE_info(file_handle* file) {
}

s32 deviceHandler_WODE_readDir(file_handle* ffile, file_handle** dir, u32 type){
if(type != -1) return -1;

if(!wodeInited) return 0;
uiDrawObj_t *msgBox = DrawPublish(DrawProgressBar(true, 0, "Reading WODE"));
Expand Down
13 changes: 10 additions & 3 deletions cube/swiss/source/swiss.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,8 +862,13 @@ bool select_dest_dir(file_handle* initial, file_handle* selection)
if(refresh) {
free(directory);
free(curDirEntries);
curDirEntries = NULL;
num_files = devices[DEVICE_DEST]->readDir(&curDir, &curDirEntries, IS_DIR);
num_files = sortFiles(curDirEntries, num_files, &directory);
if(num_files <= 1 && destDirBox == NULL) {
memcpy(selection, &curDir, sizeof(file_handle));
break;
}
refresh = idx = 0;
scrollBarTabHeight = (int)((float)scrollBarHeight/(float)num_files);
}
Expand All @@ -876,7 +881,7 @@ bool select_dest_dir(file_handle* initial, file_handle* selection)
for(j = 0; i<max; ++i,++j) {
DrawAddChild(tempBox, DrawSelectableButton(50,fileListBase+(j*40), getVideoMode()->fbWidth-35, fileListBase+(j*40)+40, getRelativeName(directory[i]->name), (i == idx) ? B_SELECTED:B_NOSELECT));
}
if(destDirBox) {
if(destDirBox != NULL) {
DrawDispose(destDirBox);
}
destDirBox = tempBox;
Expand Down Expand Up @@ -911,7 +916,9 @@ bool select_dest_dir(file_handle* initial, file_handle* selection)
while (!(!(padsButtonsHeld() & PAD_BUTTON_X) && !(padsButtonsHeld() & (PAD_BUTTON_X|PAD_BUTTON_A|PAD_BUTTON_B|PAD_BUTTON_UP|PAD_BUTTON_DOWN))))
{ VIDEO_WaitVSync (); }
}
DrawDispose(destDirBox);
if(destDirBox != NULL) {
DrawDispose(destDirBox);
}
free(curDirEntries);
free(directory);
return cancelled;
Expand Down Expand Up @@ -2802,7 +2809,7 @@ void menu_loop()
else {
filePanel = renderFileBrowser(getSortedDirEntries(), getSortedDirEntryCount(), filePanel);
}
while(padsButtonsHeld() & (PAD_BUTTON_B | PAD_BUTTON_A | PAD_BUTTON_RIGHT | PAD_BUTTON_LEFT)) {
while(padsButtonsHeld() & (PAD_BUTTON_B | PAD_BUTTON_A | PAD_BUTTON_RIGHT | PAD_BUTTON_LEFT | PAD_BUTTON_START)) {
VIDEO_WaitVSync ();
}
}
Expand Down

0 comments on commit bf92c89

Please sign in to comment.