From 9c0b2479f7025a84444adf08e3be8ced60dad013 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Sun, 1 Aug 2010 16:15:27 +0000 Subject: Rockbox as an application: add get_user_file_path(). For RaaA it evaluates user paths at runtime. For everything but codecs/plugins it will give the path under $HOME/.config/rockbox.org if write access is needed or if the file/folder in question exists there (otherwise it gives /usr/local/share/rockbox). This allows for installing themes under $HOME as well as having config.cfg and other important files there while installing the application (and default themes) under /usr/local. On the DAPs it's a no-op, returing /.rockbox directly. Not converted to use get_user_file_path() are plugins themselves, because RaaA doesn't build plugins yet. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27656 a1c6a512-1295-4272-9138-f99709370657 --- firmware/font.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'firmware/font.c') diff --git a/firmware/font.c b/firmware/font.c index f1584713ed..b8ad76ec3a 100644 --- a/firmware/font.c +++ b/firmware/font.c @@ -36,6 +36,7 @@ #include "panic.h" #include "rbunicode.h" #include "diacritic.h" +#include "rbpaths.h" #define MAX_FONTSIZE_FOR_16_BIT_OFFSETS 0xFFDB @@ -56,7 +57,6 @@ #define FONT_HEADER_SIZE 36 #endif -#define GLYPH_CACHE_FILE ROCKBOX_DIR"/.glyphcache" #ifndef BOOTLOADER /* Font cache includes */ @@ -606,12 +606,13 @@ void glyph_cache_save(struct font* pf) pf = &font_ui; if (pf->fd >= 0 && pf == &font_ui) { -#ifdef WPSEDITOR - cache_fd = open(GLYPH_CACHE_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0666); -#else - cache_fd = creat(GLYPH_CACHE_FILE, 0666); -#endif - if (cache_fd < 0) return; + char path[MAX_PATH]; + const char *file = get_user_file_path(GLYPH_CACHE_FILE, IS_FILE|NEED_WRITE, + path, sizeof(path)); + + cache_fd = open(file, O_WRONLY|O_CREAT|O_TRUNC, 0666); + if (cache_fd < 0) + return; lru_traverse(&pf->cache._lru, glyph_file_write); @@ -630,9 +631,10 @@ static void glyph_cache_load(struct font* pf) int fd; unsigned char tmp[2]; unsigned short ch; + char path[MAX_PATH]; - fd = open(GLYPH_CACHE_FILE, O_RDONLY|O_BINARY); - + fd = open(get_user_file_path(GLYPH_CACHE_FILE, IS_FILE|NEED_WRITE, + path, sizeof(path)), O_RDONLY|O_BINARY); if (fd >= 0) { while (read(fd, tmp, 2) == 2) { -- cgit v1.2.3