summaryrefslogtreecommitdiffstats
path: root/apps/root_menu.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-11-26 00:37:27 +0000
committerThomas Martitz <kugel@rockbox.org>2009-11-26 00:37:27 +0000
commit1ecb7536689277d934a3584c27a142cd0f19d0ac (patch)
tree43e57bedb292669536d7b3267fe17cc31a21cf2e /apps/root_menu.c
parent10753f195bb14413e179ae3091b633c636973760 (diff)
downloadrockbox-1ecb7536689277d934a3584c27a142cd0f19d0ac.tar.gz
rockbox-1ecb7536689277d934a3584c27a142cd0f19d0ac.tar.bz2
rockbox-1ecb7536689277d934a3584c27a142cd0f19d0ac.zip
Redo a hack that precluded entering a folder on an ejected hotswap drive. Use storage api and proper defines for the drive folder instead.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23755 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/root_menu.c')
-rw-r--r--apps/root_menu.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/apps/root_menu.c b/apps/root_menu.c
index b02d2a1be8..e475db1f5d 100644
--- a/apps/root_menu.c
+++ b/apps/root_menu.c
@@ -37,8 +37,12 @@
#include "power.h"
#include "talk.h"
#include "audio.h"
-#include "hotswap.h"
+#ifdef HAVE_HOTSWAP
+#include "storage.h"
+#include "hotswap.h"
+#include "dir.h"
+#endif
/* gui api */
#include "list.h"
#include "splash.h"
@@ -110,14 +114,37 @@ static int browser(void* param)
{
strcpy(folder, current_track_path);
}
-#ifdef HAVE_HOTSWAP /* quick hack to stop crashing if you try entering
- the browser from the menu when you were in the card
- and it was removed */
- else if (strchr(last_folder, '<') && (card_detect() == false))
- strcpy(folder, "/");
-#endif
else
+ {
+#ifdef HAVE_HOTSWAP
+ bool in_hotswap = false;
+ /* handle entering an ejected drive */
+ int i;
+ for (i = 0; i < NUM_VOLUMES; i++)
+ {
+ char vol_string[VOL_ENUM_POS + 8];
+ if (!storage_removable(i))
+ continue;
+ /* VOL_NAMES contains a %d */
+ snprintf(vol_string, sizeof(vol_string), "/"VOL_NAMES, i);
+ /* test whether we would browse the external card */
+ if (!storage_present(i) &&
+ (strstr(last_folder, vol_string)
+#ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN
+ || (i == 0)
+#endif
+ ))
+ { /* leave folder as "/" to avoid crash when trying
+ * to access an ejected drive */
+ strcpy(folder, "/");
+ in_hotswap = true;
+ break;
+ }
+ }
+ if (!in_hotswap)
+#endif
strcpy(folder, last_folder);
+ }
break;
#ifdef HAVE_TAGCACHE
case GO_TO_DBBROWSER: