From e61c87570c6e986aab1f9208cb6fb1274d0245f3 Mon Sep 17 00:00:00 2001 From: "fabio.olimpieri" Date: Fri, 18 Jan 2013 19:18:28 +0000 Subject: [PATCH] Fixed bug in dir browsing, fixed check on device selection --- src/emulator.c | 45 ++++++++++++++++++++++++++++++++------------- src/menu_sdl.c | 7 +++++-- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/emulator.c b/src/emulator.c index 8e567d1..824fce0 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -1143,7 +1143,7 @@ int main(int argc,char *argv[]) { if (fatInitDefault()) printf("FAT subsytem initialized\n"); else - printf("Couldn't initialize fat subsytem\n"); + printf("Couldn't initialize FAT subsytem\n"); DIR *dp; @@ -1379,21 +1379,40 @@ int main(int argc,char *argv[]) { else {printf("Can't make tmp directory\n"); tmpismade=0;} #ifdef GEKKO - if ((ordenador.port==1)&&sdismount) { - strcpy(path_snaps,"sd:/"); - strcpy(path_taps,"sd:/"); + switch (ordenador.port) + { + case 1: //SD + if (sdismount) + { + strcpy(path_snaps,"sd:/"); + strcpy(path_taps,"sd:/"); } - if ((ordenador.port==2)&&usbismount) { - strcpy(path_snaps,"usb:/"); - strcpy(path_taps,"usb:/"); + else ordenador.port =0; + break; + case 2: //USB + if (usbismount) + { + strcpy(path_snaps,"usb:/"); + strcpy(path_taps,"usb:/"); } - if ((ordenador.port==3)&&smbismount) { - strcpy(path_snaps,"smb:/"); - strcpy(path_taps,"smb:/"); + else ordenador.port =0; + break; + case 3: //SMB + if (smbismount) + { + strcpy(path_snaps,"smb:/"); + strcpy(path_taps,"smb:/"); } - if ((ordenador.port==4)&&ftpismount) { - strcpy(path_snaps,"ftp:"); - strcpy(path_taps,"ftp:"); + else ordenador.port =0; + break; + case 4: //FTP + if (ftpismount) + { + strcpy(path_snaps,"ftp:"); + strcpy(path_taps,"ftp:"); + } + else ordenador.port =0; + break; } #endif diff --git a/src/menu_sdl.c b/src/menu_sdl.c index 16987ee..92c85cb 100644 --- a/src/menu_sdl.c +++ b/src/menu_sdl.c @@ -1311,8 +1311,11 @@ static const char *menu_select_file_internal(char *dir_path, { free((void*)sel); updir=strrchr(dir_path,'/'); - if ((updir!=NULL)&&(updir!=dir_path)) // or "/" and not root dir - *updir=0; //trunk dir_path at last / + if (updir!=NULL) // found "/" + { + *updir=0; //trunk dir_path at last / + if (strrchr(dir_path,'/')==NULL) {*updir='/'; *(updir+1)=0;} //check if it was root + } return menu_select_file(dir_path, selected_file, draw_scr); }