diff options
Diffstat (limited to 'apps/root_menu.c')
-rw-r--r-- | apps/root_menu.c | 41 |
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 @@ | |||
37 | #include "power.h" | 37 | #include "power.h" |
38 | #include "talk.h" | 38 | #include "talk.h" |
39 | #include "audio.h" | 39 | #include "audio.h" |
40 | #include "hotswap.h" | ||
41 | 40 | ||
41 | #ifdef HAVE_HOTSWAP | ||
42 | #include "storage.h" | ||
43 | #include "hotswap.h" | ||
44 | #include "dir.h" | ||
45 | #endif | ||
42 | /* gui api */ | 46 | /* gui api */ |
43 | #include "list.h" | 47 | #include "list.h" |
44 | #include "splash.h" | 48 | #include "splash.h" |
@@ -110,14 +114,37 @@ static int browser(void* param) | |||
110 | { | 114 | { |
111 | strcpy(folder, current_track_path); | 115 | strcpy(folder, current_track_path); |
112 | } | 116 | } |
113 | #ifdef HAVE_HOTSWAP /* quick hack to stop crashing if you try entering | ||
114 | the browser from the menu when you were in the card | ||
115 | and it was removed */ | ||
116 | else if (strchr(last_folder, '<') && (card_detect() == false)) | ||
117 | strcpy(folder, "/"); | ||
118 | #endif | ||
119 | else | 117 | else |
118 | { | ||
119 | #ifdef HAVE_HOTSWAP | ||
120 | bool in_hotswap = false; | ||
121 | /* handle entering an ejected drive */ | ||
122 | int i; | ||
123 | for (i = 0; i < NUM_VOLUMES; i++) | ||
124 | { | ||
125 | char vol_string[VOL_ENUM_POS + 8]; | ||
126 | if (!storage_removable(i)) | ||
127 | continue; | ||
128 | /* VOL_NAMES contains a %d */ | ||
129 | snprintf(vol_string, sizeof(vol_string), "/"VOL_NAMES, i); | ||
130 | /* test whether we would browse the external card */ | ||
131 | if (!storage_present(i) && | ||
132 | (strstr(last_folder, vol_string) | ||
133 | #ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN | ||
134 | || (i == 0) | ||
135 | #endif | ||
136 | )) | ||
137 | { /* leave folder as "/" to avoid crash when trying | ||
138 | * to access an ejected drive */ | ||
139 | strcpy(folder, "/"); | ||
140 | in_hotswap = true; | ||
141 | break; | ||
142 | } | ||
143 | } | ||
144 | if (!in_hotswap) | ||
145 | #endif | ||
120 | strcpy(folder, last_folder); | 146 | strcpy(folder, last_folder); |
147 | } | ||
121 | break; | 148 | break; |
122 | #ifdef HAVE_TAGCACHE | 149 | #ifdef HAVE_TAGCACHE |
123 | case GO_TO_DBBROWSER: | 150 | case GO_TO_DBBROWSER: |