summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/playlist_catalog.c4
-rw-r--r--apps/plugin.h2
-rw-r--r--apps/tree.c35
-rw-r--r--apps/tree.h2
4 files changed, 16 insertions, 27 deletions
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c
index ef44e36ba7..5f9f46728a 100644
--- a/apps/playlist_catalog.c
+++ b/apps/playlist_catalog.c
@@ -70,7 +70,9 @@ static int initialize_catalog(void)
bool default_dir = true;
/* directory config is of the format: "dir: /path/to/dir" */
- if (global_settings.playlist_catalog_dir[0])
+ if (global_settings.playlist_catalog_dir[0] &&
+ strcmp(global_settings.playlist_catalog_dir,
+ PLAYLIST_CATALOG_DEFAULT_DIR))
{
strcpy(playlist_dir, global_settings.playlist_catalog_dir);
default_dir = false;
diff --git a/apps/plugin.h b/apps/plugin.h
index faea8470f0..56e0bfcd04 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -831,7 +831,7 @@ struct plugin_api {
#endif
int (*show_logo)(void);
struct tree_context* (*tree_get_context)(void);
- void (*set_current_file)(char* path);
+ void (*set_current_file)(const char* path);
void (*set_dirfilter)(int l_dirfilter);
#ifdef HAVE_WHEEL_POSITION
diff --git a/apps/tree.c b/apps/tree.c
index 01a00d1f40..86238c50d9 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -563,9 +563,9 @@ void set_dirfilter(int l_dirfilter)
}
/* Selects a file and update tree context properly */
-void set_current_file(char *path)
+void set_current_file(const char *path)
{
- char *name;
+ const char *name;
int i;
#ifdef HAVE_TAGCACHE
@@ -580,9 +580,7 @@ void set_current_file(char *path)
name = strrchr(path+1,'/');
if (name)
{
- *name = 0;
- strcpy(tc.currdir, path);
- *name = '/';
+ strlcpy(tc.currdir, path, name - path + 1);
name++;
}
else
@@ -929,6 +927,7 @@ bool create_playlist(void)
int rockbox_browse(const char *root, int dirfilter)
{
+ static char current[MAX_PATH];
int ret_val = 0;
int *last_filter = tc.dirfilter;
tc.dirfilter = &dirfilter;
@@ -939,7 +938,7 @@ int rockbox_browse(const char *root, int dirfilter)
{
static struct tree_context backup;
int last_context;
- const char *dir, *ext, *setting = NULL;
+ const char *ext, *setting;
backup = tc;
tc.selected_item = 0;
@@ -952,7 +951,6 @@ int rockbox_browse(const char *root, int dirfilter)
switch(dirfilter)
{
case SHOW_LNG:
- dir = LANG_DIR;
ext = "lng";
if (global_settings.lang_file[0])
setting = global_settings.lang_file;
@@ -960,24 +958,20 @@ int rockbox_browse(const char *root, int dirfilter)
setting = "english";
break;
case SHOW_WPS:
- dir = WPS_DIR;
ext = "wps";
setting = global_settings.wps_file;
break;
#ifdef HAVE_REMOTE_LCD
case SHOW_RWPS:
- dir = WPS_DIR;
ext = "rwps";
setting = global_settings.rwps_file;
break;
case SHOW_RSBS:
- dir = WPS_DIR;
ext = "rsbs";
setting = global_settings.rsbs_file;
break;
#if CONFIG_TUNER
case SHOW_RFMS:
- dir = WPS_DIR;
ext = "rfms";
setting = global_settings.rfms_file;
break;
@@ -985,18 +979,15 @@ int rockbox_browse(const char *root, int dirfilter)
#endif
#ifdef HAVE_LCD_BITMAP
case SHOW_FONT:
- dir = FONT_DIR;
ext = "fnt";
setting = global_settings.font_file;
break;
case SHOW_SBS:
- dir = WPS_DIR;
ext = "sbs";
setting = global_settings.sbs_file;
break;
#if CONFIG_TUNER
case SHOW_FMS:
- dir = WPS_DIR;
ext = "fms";
setting = global_settings.fms_file;
break;
@@ -1004,23 +995,20 @@ int rockbox_browse(const char *root, int dirfilter)
#endif
#if CONFIG_TUNER
case SHOW_FMR:
- dir = FMPRESET_PATH;
ext = "fmr";
setting = global_settings.fmr_file;
break;
#endif
default:
- dir = ext = setting = NULL;
+ ext = setting = NULL;
break;
- }
+ }
/* If we've found a file to center on, do it */
if (setting)
{
- char current[MAX_PATH], _dir[MAX_PATH];
- /* if setting != NULL, ext and dir are not used uninitialized */
- snprintf(current, sizeof(current), "%s/%s.%s",
- get_user_file_path(dir, 0, _dir, sizeof(_dir)), setting, ext);
+ /* if setting != NULL, ext is initialized */
+ snprintf(current, sizeof(current), "%s/%s.%s", root, setting, ext);
set_current_file(current);
/* set_current_file changes dirlevel, change it back */
tc.dirlevel = 0;
@@ -1032,11 +1020,10 @@ int rockbox_browse(const char *root, int dirfilter)
}
else
{
- static char buf[MAX_PATH];
if (dirfilter != SHOW_ID3DB)
tc.dirfilter = &global_settings.dirfilter;
- strcpy(buf,root);
- set_current_file(buf);
+ strcpy(current,root);
+ set_current_file(current);
ret_val = dirbrowse();
}
tc.dirfilter = last_filter;
diff --git a/apps/tree.h b/apps/tree.h
index 993d1b4569..a74960f7a5 100644
--- a/apps/tree.h
+++ b/apps/tree.h
@@ -75,7 +75,7 @@ void tree_mem_init(void) INIT_ATTR;
void tree_gui_init(void) INIT_ATTR;
char* get_current_file(char* buffer, size_t buffer_len);
void set_dirfilter(int l_dirfilter);
-void set_current_file(char *path);
+void set_current_file(const char *path);
int rockbox_browse(const char *root, int dirfilter);
bool create_playlist(void);
void resume_directory(const char *dir);