summaryrefslogtreecommitdiff
path: root/firmware/font.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-08-01 16:15:27 +0000
committerThomas Martitz <kugel@rockbox.org>2010-08-01 16:15:27 +0000
commit9c0b2479f7025a84444adf08e3be8ced60dad013 (patch)
treef3d328dd73f46d599f0432cc43ae206798cbe4f6 /firmware/font.c
parent2e7d92fef707a2cd30820fd0053c539c3ac8e2b3 (diff)
downloadrockbox-9c0b2479f7025a84444adf08e3be8ced60dad013.tar.gz
rockbox-9c0b2479f7025a84444adf08e3be8ced60dad013.zip
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.c20
1 files changed, 11 insertions, 9 deletions
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 @@
36#include "panic.h" 36#include "panic.h"
37#include "rbunicode.h" 37#include "rbunicode.h"
38#include "diacritic.h" 38#include "diacritic.h"
39#include "rbpaths.h"
39 40
40#define MAX_FONTSIZE_FOR_16_BIT_OFFSETS 0xFFDB 41#define MAX_FONTSIZE_FOR_16_BIT_OFFSETS 0xFFDB
41 42
@@ -56,7 +57,6 @@
56#define FONT_HEADER_SIZE 36 57#define FONT_HEADER_SIZE 36
57#endif 58#endif
58 59
59#define GLYPH_CACHE_FILE ROCKBOX_DIR"/.glyphcache"
60 60
61#ifndef BOOTLOADER 61#ifndef BOOTLOADER
62/* Font cache includes */ 62/* Font cache includes */
@@ -606,12 +606,13 @@ void glyph_cache_save(struct font* pf)
606 pf = &font_ui; 606 pf = &font_ui;
607 if (pf->fd >= 0 && pf == &font_ui) 607 if (pf->fd >= 0 && pf == &font_ui)
608 { 608 {
609#ifdef WPSEDITOR 609 char path[MAX_PATH];
610 cache_fd = open(GLYPH_CACHE_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0666); 610 const char *file = get_user_file_path(GLYPH_CACHE_FILE, IS_FILE|NEED_WRITE,
611#else 611 path, sizeof(path));
612 cache_fd = creat(GLYPH_CACHE_FILE, 0666); 612
613#endif 613 cache_fd = open(file, O_WRONLY|O_CREAT|O_TRUNC, 0666);
614 if (cache_fd < 0) return; 614 if (cache_fd < 0)
615 return;
615 616
616 lru_traverse(&pf->cache._lru, glyph_file_write); 617 lru_traverse(&pf->cache._lru, glyph_file_write);
617 618
@@ -630,9 +631,10 @@ static void glyph_cache_load(struct font* pf)
630 int fd; 631 int fd;
631 unsigned char tmp[2]; 632 unsigned char tmp[2];
632 unsigned short ch; 633 unsigned short ch;
634 char path[MAX_PATH];
633 635
634 fd = open(GLYPH_CACHE_FILE, O_RDONLY|O_BINARY); 636 fd = open(get_user_file_path(GLYPH_CACHE_FILE, IS_FILE|NEED_WRITE,
635 637 path, sizeof(path)), O_RDONLY|O_BINARY);
636 if (fd >= 0) { 638 if (fd >= 0) {
637 639
638 while (read(fd, tmp, 2) == 2) { 640 while (read(fd, tmp, 2) == 2) {