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.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/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 130c5ff..3745c6b 100644
--- a/firmware/export/filefuncs.h
+++ b/firmware/export/filefuncs.h
@@ -28,4 +28,9 @@
int strip_volume(const char* name, char* namecopy);
#endif
+#ifndef __PCTOOL__
+bool file_exists(const char *file);
+bool dir_exists(const char *path);
+#endif
+
#endif /* __INCLUDE_FILEFUNCS_H_ */
diff --git a/firmware/export/rbpaths.h b/firmware/export/rbpaths.h
new file mode 100644
index 0000000..cd87888
--- /dev/null
+++ b/firmware/export/rbpaths.h
@@ -0,0 +1,132 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 Thomas Martitz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef __PATHS_H__
+#define __PATHS_H__
+
+#include <stdbool.h>
+#include "autoconf.h"
+#include "string-extra.h"
+
+/* flags for get_user_file_path() */
+/* whether you need write access to that file/dir, especially true
+ * for runtime generated files (config.cfg) */
+#define NEED_WRITE (1<<0)
+/* file or directory? */
+#define IS_FILE (1<<1)
+/* make sure the path is copied into the passed buffer (it may return
+ * the passed path directly otherwise, e.g. always on target builds) */
+#define FORCE_BUFFER_COPY (1<<2)
+
+
+
+/* name of directory where configuration, fonts and other data
+ * files are stored */
+#ifdef __PCTOOL__
+#undef ROCKBOX_DIR
+#undef ROCKBOX_DIR_LEN
+#undef WPS_DIR
+#define ROCKBOX_DIR "."
+#define ROCKBOX_DIR_LEN 1
+#else
+
+/* ROCKBOX_DIR is now defined in autoconf.h for flexible build types */
+#ifndef ROCKBOX_DIR
+#error ROCKBOX_DIR not defined (should be in autoconf.h)
+#endif
+#define ROCKBOX_DIR_LEN (sizeof(ROCKBOX_DIR)-1)
+#endif /* def __PCTOOL__ */
+
+#ifndef APPLICATION
+
+/* make sure both are the same for native builds */
+#undef ROCKBOX_LIBRARY_PATH
+#define ROCKBOX_LIBRARY_PATH ROCKBOX_DIR
+
+#define PLUGIN_DIR ROCKBOX_DIR "/rocks"
+#define CODECS_DIR ROCKBOX_DIR "/codecs"
+
+#define REC_BASE_DIR "/"
+#define PLAYLIST_CATALOG_DEFAULT_DIR "/Playlists"
+
+#ifndef PLUGIN
+static inline __attribute__((always_inline)) const char* get_user_file_path(const char *path,
+ unsigned flags,
+ char* buf,
+ const size_t bufsize)
+{
+ if (flags & FORCE_BUFFER_COPY)
+ {
+ strlcpy(buf, path, bufsize);
+ return buf;
+ }
+ return path;
+}
+#endif
+
+#define paths_init()
+#else /* application */
+
+#define PLUGIN_DIR ROCKBOX_LIBRARY_PATH "/rockbox/rocks"
+#define CODECS_DIR ROCKBOX_LIBRARY_PATH "/rockbox/codecs"
+
+#define REC_BASE_DIR ROCKBOX_DIR "/"
+#define PLAYLIST_CATALOG_DEFAULT_DIR ROCKBOX_DIR "/Playlists"
+
+extern void paths_init(void);
+extern const char* get_user_file_path(const char *path,
+ unsigned flags,
+ char* buf,
+ const size_t bufsize);
+#endif /* APPLICATION */
+
+#define LANG_DIR ROCKBOX_DIR "/langs"
+
+#define PLUGIN_GAMES_DIR PLUGIN_DIR "/games"
+#define PLUGIN_APPS_DIR PLUGIN_DIR "/apps"
+#define PLUGIN_DEMOS_DIR PLUGIN_DIR "/demos"
+#define VIEWERS_DIR PLUGIN_DIR "/viewers"
+
+
+#define WPS_DIR ROCKBOX_DIR "/wps"
+#define SBS_DIR WPS_DIR
+#define THEME_DIR ROCKBOX_DIR "/themes"
+#define FONT_DIR ROCKBOX_DIR "/fonts"
+#define ICON_DIR ROCKBOX_DIR "/icons"
+
+#define BACKDROP_DIR ROCKBOX_DIR "/backdrops"
+#define EQS_DIR ROCKBOX_DIR "/eqs"
+
+/* need to fix this once the application gets record/radio abilities */
+#define RECPRESETS_DIR ROCKBOX_DIR "/recpresets"
+#define FMPRESET_PATH ROCKBOX_DIR "/fmpresets"
+
+#define DIRCACHE_FILE ROCKBOX_DIR "/dircache.dat"
+#define CODEPAGE_DIR ROCKBOX_DIR "/codepages"
+
+#define VIEWERS_CONFIG ROCKBOX_DIR "/viewers.config"
+#define CONFIGFILE ROCKBOX_DIR "/config.cfg"
+#define FIXEDSETTINGSFILE ROCKBOX_DIR "/fixed.cfg"
+
+#define PLAYLIST_CONTROL_FILE ROCKBOX_DIR "/.playlist_control"
+#define NVRAM_FILE ROCKBOX_DIR "/nvram.bin"
+#define GLYPH_CACHE_FILE ROCKBOX_DIR "/.glyphcache"
+#endif /* __PATHS_H__ */