summaryrefslogtreecommitdiff
path: root/firmware/export
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/export
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/export')
-rw-r--r--firmware/export/filefuncs.h5
-rw-r--r--firmware/export/rbpaths.h132
2 files changed, 137 insertions, 0 deletions
diff --git a/firmware/export/filefuncs.h b/firmware/export/filefuncs.h
index 130c5ff4be..3745c6bee3 100644
--- a/firmware/export/filefuncs.h
+++ b/firmware/export/filefuncs.h
@@ -28,4 +28,9 @@
28int strip_volume(const char* name, char* namecopy); 28int strip_volume(const char* name, char* namecopy);
29#endif 29#endif
30 30
31#ifndef __PCTOOL__
32bool file_exists(const char *file);
33bool dir_exists(const char *path);
34#endif
35
31#endif /* __INCLUDE_FILEFUNCS_H_ */ 36#endif /* __INCLUDE_FILEFUNCS_H_ */
diff --git a/firmware/export/rbpaths.h b/firmware/export/rbpaths.h
new file mode 100644
index 0000000000..cd87888cef
--- /dev/null
+++ b/firmware/export/rbpaths.h
@@ -0,0 +1,132 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef __PATHS_H__
23#define __PATHS_H__
24
25#include <stdbool.h>
26#include "autoconf.h"
27#include "string-extra.h"
28
29/* flags for get_user_file_path() */
30/* whether you need write access to that file/dir, especially true
31 * for runtime generated files (config.cfg) */
32#define NEED_WRITE (1<<0)
33/* file or directory? */
34#define IS_FILE (1<<1)
35/* make sure the path is copied into the passed buffer (it may return
36 * the passed path directly otherwise, e.g. always on target builds) */
37#define FORCE_BUFFER_COPY (1<<2)
38
39
40
41/* name of directory where configuration, fonts and other data
42 * files are stored */
43#ifdef __PCTOOL__
44#undef ROCKBOX_DIR
45#undef ROCKBOX_DIR_LEN
46#undef WPS_DIR
47#define ROCKBOX_DIR "."
48#define ROCKBOX_DIR_LEN 1
49#else
50
51/* ROCKBOX_DIR is now defined in autoconf.h for flexible build types */
52#ifndef ROCKBOX_DIR
53#error ROCKBOX_DIR not defined (should be in autoconf.h)
54#endif
55#define ROCKBOX_DIR_LEN (sizeof(ROCKBOX_DIR)-1)
56#endif /* def __PCTOOL__ */
57
58#ifndef APPLICATION
59
60/* make sure both are the same for native builds */
61#undef ROCKBOX_LIBRARY_PATH
62#define ROCKBOX_LIBRARY_PATH ROCKBOX_DIR
63
64#define PLUGIN_DIR ROCKBOX_DIR "/rocks"
65#define CODECS_DIR ROCKBOX_DIR "/codecs"
66
67#define REC_BASE_DIR "/"
68#define PLAYLIST_CATALOG_DEFAULT_DIR "/Playlists"
69
70#ifndef PLUGIN
71static inline __attribute__((always_inline)) const char* get_user_file_path(const char *path,
72 unsigned flags,
73 char* buf,
74 const size_t bufsize)
75{
76 if (flags & FORCE_BUFFER_COPY)
77 {
78 strlcpy(buf, path, bufsize);
79 return buf;
80 }
81 return path;
82}
83#endif
84
85#define paths_init()
86#else /* application */
87
88#define PLUGIN_DIR ROCKBOX_LIBRARY_PATH "/rockbox/rocks"
89#define CODECS_DIR ROCKBOX_LIBRARY_PATH "/rockbox/codecs"
90
91#define REC_BASE_DIR ROCKBOX_DIR "/"
92#define PLAYLIST_CATALOG_DEFAULT_DIR ROCKBOX_DIR "/Playlists"
93
94extern void paths_init(void);
95extern const char* get_user_file_path(const char *path,
96 unsigned flags,
97 char* buf,
98 const size_t bufsize);
99#endif /* APPLICATION */
100
101#define LANG_DIR ROCKBOX_DIR "/langs"
102
103#define PLUGIN_GAMES_DIR PLUGIN_DIR "/games"
104#define PLUGIN_APPS_DIR PLUGIN_DIR "/apps"
105#define PLUGIN_DEMOS_DIR PLUGIN_DIR "/demos"
106#define VIEWERS_DIR PLUGIN_DIR "/viewers"
107
108
109#define WPS_DIR ROCKBOX_DIR "/wps"
110#define SBS_DIR WPS_DIR
111#define THEME_DIR ROCKBOX_DIR "/themes"
112#define FONT_DIR ROCKBOX_DIR "/fonts"
113#define ICON_DIR ROCKBOX_DIR "/icons"
114
115#define BACKDROP_DIR ROCKBOX_DIR "/backdrops"
116#define EQS_DIR ROCKBOX_DIR "/eqs"
117
118/* need to fix this once the application gets record/radio abilities */
119#define RECPRESETS_DIR ROCKBOX_DIR "/recpresets"
120#define FMPRESET_PATH ROCKBOX_DIR "/fmpresets"
121
122#define DIRCACHE_FILE ROCKBOX_DIR "/dircache.dat"
123#define CODEPAGE_DIR ROCKBOX_DIR "/codepages"
124
125#define VIEWERS_CONFIG ROCKBOX_DIR "/viewers.config"
126#define CONFIGFILE ROCKBOX_DIR "/config.cfg"
127#define FIXEDSETTINGSFILE ROCKBOX_DIR "/fixed.cfg"
128
129#define PLAYLIST_CONTROL_FILE ROCKBOX_DIR "/.playlist_control"
130#define NVRAM_FILE ROCKBOX_DIR "/nvram.bin"
131#define GLYPH_CACHE_FILE ROCKBOX_DIR "/.glyphcache"
132#endif /* __PATHS_H__ */