summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-08-02 19:13:22 +0000
committerThomas Martitz <kugel@rockbox.org>2010-08-02 19:13:22 +0000
commit850efead04f10488b478a0f255a2464a01156a7f (patch)
tree44539bf63d893479c83f8cee8c4a9ca09b773dc5 /apps
parent75556fd57ff70be9a9cbc183cbacb71db520291d (diff)
A few post-fixes to the get_user_file_path() commit.
Remove unneeded restriction from set_file that prevented filename settings to work if they were outside of ROCKBOX_DIR. Add the get_user_file_path() call to a few further places where it was forgotten. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27667 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/filetypes.c5
-rw-r--r--apps/settings.c21
-rw-r--r--apps/tree.c5
3 files changed, 19 insertions, 12 deletions
diff --git a/apps/filetypes.c b/apps/filetypes.c
index 67a4c176fb..28a2da65bb 100644
--- a/apps/filetypes.c
+++ b/apps/filetypes.c
@@ -182,14 +182,15 @@ static void read_config(const char* config_file);
* load a colors file from a theme with:
* filetype colours: filename.colours */
void read_color_theme_file(void) {
- char buffer[MAX_PATH];
+ char buffer[MAX_PATH], dir[MAX_PATH];
int fd;
char *ext, *color;
int i;
for (i = 0; i < MAX_FILETYPES+1; i++) {
custom_colors[i] = -1;
}
- snprintf(buffer, MAX_PATH, "%s/%s.colours", THEME_DIR,
+ snprintf(buffer, MAX_PATH, "%s/%s.colours",
+ get_user_file_path(THEME_DIR, 0, dir, sizeof(dir)),
global_settings.colors_file);
fd = open(buffer, O_RDONLY);
if (fd < 0)
diff --git a/apps/settings.c b/apps/settings.c
index 58585d60e1..5a61e6db53 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -886,10 +886,13 @@ void settings_apply(bool read_disk)
{
char buf[MAX_PATH];
#ifdef HAVE_LCD_BITMAP
+ char dir[MAX_PATH];
+ const char *font_path = get_user_file_path(FONT_DIR, 0, dir, sizeof(dir));
/* fonts need to be loaded before the WPS */
if (global_settings.font_file[0]
&& global_settings.font_file[0] != '-') {
- snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
+
+ snprintf(buf, sizeof buf, "%s/%s.fnt", font_path,
global_settings.font_file);
CHART2(">font_load ", global_settings.font_file);
rc = font_load(NULL, buf);
@@ -902,7 +905,7 @@ void settings_apply(bool read_disk)
#ifdef HAVE_REMOTE_LCD
if ( global_settings.remote_font_file[0]
&& global_settings.remote_font_file[0] != '-') {
- snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
+ snprintf(buf, sizeof buf, "%s/%s.fnt", font_path,
global_settings.remote_font_file);
CHART2(">font_load_remoteui ", global_settings.remote_font_file);
rc = font_load_remoteui(buf);
@@ -914,7 +917,8 @@ void settings_apply(bool read_disk)
font_load_remoteui(NULL);
#endif
if ( global_settings.kbd_file[0]) {
- snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd",
+ snprintf(buf, sizeof buf, "%s/%s.kbd",
+ get_user_file_path(ROCKBOX_DIR, 0, dir, sizeof(dir)),
global_settings.kbd_file);
CHART(">load_kbd");
load_kbd(buf);
@@ -922,8 +926,9 @@ void settings_apply(bool read_disk)
}
else
load_kbd(NULL);
-#endif
-
+#endif /* HAVE_LCD_BITMAP */
+ /* no get_user_file_path() here because we don't really support
+ * langs that don't come with rockbox */
if ( global_settings.lang_file[0]) {
snprintf(buf, sizeof buf, LANG_DIR "/%s.lng",
global_settings.lang_file);
@@ -1208,8 +1213,8 @@ bool set_option(const char* string, const void* variable, enum optiontype type,
}
/*
- * Takes filename, removes the directory (assumed to be ROCKBOX_DIR) its in
- * and the extension, and then copies the basename into setting
+ * Takes filename, removes the directory and the extension,
+ * and then copies the basename into setting, unless the basename exceeds maxlen
**/
void set_file(const char* filename, char* setting, const int maxlen)
{
@@ -1233,7 +1238,7 @@ void set_file(const char* filename, char* setting, const int maxlen)
len = strlen(fptr) - extlen + 1;
/* error if filename isn't in ROCKBOX_DIR */
- if (strncasecmp(ROCKBOX_DIR, filename, ROCKBOX_DIR_LEN) || (len > maxlen))
+ if (len > maxlen)
return;
strlcpy(setting, fptr, len);
diff --git a/apps/tree.c b/apps/tree.c
index ed8e4d20bd..c2ec4ca3ec 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -988,9 +988,10 @@ int rockbox_browse(const char *root, int dirfilter)
/* If we've found a file to center on, do it */
if (setting)
{
- char current[MAX_PATH];
+ char current[MAX_PATH], _dir[MAX_PATH];
/* if setting != NULL, ext and dir are not used uninitialized */
- snprintf(current, sizeof(current), "%s/%s.%s", dir, setting, ext);
+ snprintf(current, sizeof(current), "%s/%s.%s",
+ get_user_file_path(dir, 0, _dir, sizeof(_dir)), setting, ext);
set_current_file(current);
/* set_current_file changes dirlevel, change it back */
tc.dirlevel = 0;