summaryrefslogtreecommitdiff
path: root/apps/tree.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-05-14 23:48:18 +0000
committerJens Arnold <amiconn@rockbox.org>2005-05-14 23:48:18 +0000
commiteb8ceadc32dc5e5964609f86d9b8e063f435a4e0 (patch)
tree96b14e34e89ea7750eb0252ff6c5f852d3ffe1c5 /apps/tree.c
parent268f0b43376524b1e05e4d67f3e41a88356eea68 (diff)
Bugfixes: (all) Don't try to build the directory list when showdir() returns -1. (hotswap) Handle the 'dir no longer valid' situation in all cases, not only when the file system change happens while browsing. Force this detection when returning from wps.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6472 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/tree.c')
-rw-r--r--apps/tree.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/apps/tree.c b/apps/tree.c
index d713a2378b..12acdc8c70 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -283,7 +283,7 @@ static int showdir(void)
}
else {
if (strncmp(tc.currdir, lastdir, sizeof(lastdir)) || reload_dir) {
- if (ft_load(&tc, NULL) < 0)
+ if (ft_load(&tc, NULL) < 0)
return -1;
strcpy(lastdir, tc.currdir);
newdir = true;
@@ -1117,19 +1117,10 @@ static bool dirbrowse(void)
#ifdef HAVE_HOTSWAP
case SYS_FS_CHANGED:
- if (!id3db) /* file browsing */
- {
- if (currdir[1]) /* not in the root */
- {
- DIR *dir = opendir(currdir);
- if (dir) /* path still valid */
- {
- closedir(dir);
- break; /* don't reload the root */
- }
- }
- reload_root = true;
- }
+ if (!id3db)
+ reload_dir = true;
+ /* The 'dir no longer valid' situation will be caught later
+ * by checking the showdir() result. */
break;
#endif
@@ -1159,6 +1150,11 @@ static bool dirbrowse(void)
lcd_stop_scroll();
if (wps_show() == SYS_USB_CONNECTED)
reload_root = true;
+#ifdef HAVE_HOTSWAP
+ else
+ if (!id3db) /* Try reload to catch 'no longer valid' case. */
+ reload_dir = true;
+#endif
#ifdef HAVE_LCD_BITMAP
tree_max_on_screen = recalc_screen_height();
#endif
@@ -1167,6 +1163,9 @@ static bool dirbrowse(void)
start_wps=false;
}
+#ifdef HAVE_HOTSWAP
+ check_rescan:
+#endif
/* do we need to rescan dir? */
if (reload_dir || reload_root ||
lastfilter != *tc.dirfilter ||
@@ -1217,6 +1216,14 @@ static bool dirbrowse(void)
lcd_setfont(FONT_UI);
#endif
numentries = showdir();
+#ifdef HAVE_HOTSWAP
+ if (currdir[1] && (numentries < 0))
+ { /* not in root and reload failed */
+ reload_root = true; /* try root */
+ reload_dir = false;
+ goto check_rescan;
+ }
+#endif
update_all = true;
put_cursorxy(CURSOR_X, CURSOR_Y + tc.dircursor, true);
@@ -1224,14 +1231,14 @@ static bool dirbrowse(void)
reload_dir = false;
}
- if ( numentries && need_update) {
+ if ( (numentries > 0) && need_update) {
i = tc.dirstart+tc.dircursor;
/* if MP3 filter is on, cut off the extension */
if(lasti!=i || restore) {
char* name;
int attr = 0;
-
+
if (id3db)
name = ((char**)tc.dircache)[lasti * tc.dentry_size];
else {