diff options
| author | Thomas Martitz <kugel@rockbox.org> | 2010-08-01 16:15:27 +0000 |
|---|---|---|
| committer | Thomas Martitz <kugel@rockbox.org> | 2010-08-01 16:15:27 +0000 |
| commit | 9c0b2479f7025a84444adf08e3be8ced60dad013 (patch) | |
| tree | f3d328dd73f46d599f0432cc43ae206798cbe4f6 /firmware/font.c | |
| parent | 2e7d92fef707a2cd30820fd0053c539c3ac8e2b3 (diff) | |
| download | rockbox-9c0b2479f7025a84444adf08e3be8ced60dad013.zip rockbox-9c0b2479f7025a84444adf08e3be8ced60dad013.tar.gz rockbox-9c0b2479f7025a84444adf08e3be8ced60dad013.tar.bz2 rockbox-9c0b2479f7025a84444adf08e3be8ced60dad013.tar.xz | |
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
Diffstat (limited to 'firmware/font.c')
| -rw-r--r-- | firmware/font.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/firmware/font.c b/firmware/font.c index f158471..b8ad76e 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) { |