diff --git a/apps/root_menu.c b/apps/root_menu.c index 279b5f8bf4..f30e10c249 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c @@ -88,10 +88,10 @@ static int browser(void* param) last_screen == GO_TO_WPS && audio_status() && wps_state.current_track_path[0] != '\0') { - snprintf(folder, MAX_PATH, "%s", wps_state.current_track_path); + strcpy(folder, wps_state.current_track_path); } else - snprintf(folder, MAX_PATH, "%s/", last_folder); + strcpy(folder, last_folder); break; case GO_TO_DBBROWSER: if ((last_screen != GO_TO_ROOT) && !tagcache_is_usable()) @@ -111,7 +111,7 @@ static int browser(void* param) switch ((intptr_t)param) { case GO_TO_FILEBROWSER: - strcpy(last_folder, tc->currdir); + get_current_file(last_folder, MAX_PATH); break; case GO_TO_DBBROWSER: last_db_dirlevel = tc->dirlevel; diff --git a/apps/tree.c b/apps/tree.c index 06b42b7c86..e4237dc598 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -474,6 +474,21 @@ void reload_directory(void) reload_dir = true; } +void get_current_file(char* buffer, int buffer_len) +{ +#ifdef HAVE_TAGCACHE + /* in ID3DB mode it is a bad idea to call this function */ + /* (only happens with `follow playlist') */ + if( *tc.dirfilter == SHOW_ID3DB ) + return; +#endif + + struct entry* dc = tc.dircache; + struct entry* e = &dc[tc.selected_item]; + snprintf(buffer, buffer_len, "%s/%s", getcwd(NULL,0), + e->name); +} + /* Selects a file and update tree context properly */ void set_current_file(char *path) { @@ -505,8 +520,6 @@ void set_current_file(char *path) strcpy(lastfile, name); - /* undefined item selected */ - tc.selected_item = -1; /* If we changed dir we must recalculate the dirlevel and adjust the selected history properly */ @@ -1153,6 +1166,7 @@ int rockbox_browse(const char *root, int dirfilter) int last_context; backup = tc; + tc.selected_item = 0; tc.dirlevel = 0; memcpy(tc.currdir, root, sizeof(tc.currdir)); start_wps = false; diff --git a/apps/tree.h b/apps/tree.h index 7b202e0fbc..9fb8c233a0 100644 --- a/apps/tree.h +++ b/apps/tree.h @@ -100,6 +100,7 @@ struct tree_context { void tree_get_filetypes(const struct filetype**, int*); void tree_init(void); void browse_root(void); +void get_current_file(char* buffer, int buffer_len); void set_current_file(char *path); int rockbox_browse(const char *root, int dirfilter); bool create_playlist(void);