mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
rbpaths: Add new special dir HOME_DIR for RaaA.
HOME_DIR is intended for not-so-advanced files which shall be user visible, and thus not in /.rockbox. Therefore HOME_DIR is translated to $HOME on RaaA, /sdcard on android, the internal memory on ypr0 and "/" on native targets. ROCKBOX_DIR ("/.rockbox") already existed as special and is translated to whatever the real rockbox dir is on the target (e.g. /sdcard/rockbox on android), but it's not suitable for some files we generate (e.g. battery-bench.txt). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31430 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
16784598ac
commit
20b662a946
8 changed files with 54 additions and 52 deletions
|
@ -24,7 +24,7 @@
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
|
|
||||||
|
|
||||||
#define BATTERY_LOG "/battery_bench.txt"
|
#define BATTERY_LOG HOME_DIR"/battery_bench.txt"
|
||||||
#define BUF_SIZE 16000
|
#define BUF_SIZE 16000
|
||||||
|
|
||||||
#define EV_EXIT 1337
|
#define EV_EXIT 1337
|
||||||
|
|
|
@ -80,7 +80,7 @@ static bool log_init(bool use_logfile)
|
||||||
|
|
||||||
if (use_logfile) {
|
if (use_logfile) {
|
||||||
log_close();
|
log_close();
|
||||||
rb->create_numbered_filename(logfilename, "/", "test_codec_log_", ".txt",
|
rb->create_numbered_filename(logfilename, HOME_DIR, "test_codec_log_", ".txt",
|
||||||
2 IF_CNFN_NUM_(, NULL));
|
2 IF_CNFN_NUM_(, NULL));
|
||||||
log_fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC, 0666);
|
log_fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC, 0666);
|
||||||
return log_fd >= 0;
|
return log_fd >= 0;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define TESTBASEDIR "/__TEST__"
|
#define TESTBASEDIR HOME_DIR "/__TEST__"
|
||||||
#define TEST_FILE TESTBASEDIR "/test_disk.tmp"
|
#define TEST_FILE TESTBASEDIR "/test_disk.tmp"
|
||||||
#define FRND_SEED 0x78C3 /* arbirary */
|
#define FRND_SEED 0x78C3 /* arbirary */
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ static bool log_init(void)
|
||||||
rb->lcd_clear_display();
|
rb->lcd_clear_display();
|
||||||
rb->lcd_update();
|
rb->lcd_update();
|
||||||
|
|
||||||
rb->create_numbered_filename(logfilename, "/", "test_disk_log_", ".txt",
|
rb->create_numbered_filename(logfilename, HOME_DIR, "test_disk_log_", ".txt",
|
||||||
2 IF_CNFN_NUM_(, NULL));
|
2 IF_CNFN_NUM_(, NULL));
|
||||||
log_fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC, 0666);
|
log_fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC, 0666);
|
||||||
return log_fd >= 0;
|
return log_fd >= 0;
|
||||||
|
|
|
@ -46,7 +46,7 @@ static int log_init(void)
|
||||||
char logfilename[MAX_PATH];
|
char logfilename[MAX_PATH];
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
rb->create_numbered_filename(logfilename, "/", "test_gfx_log_", ".txt",
|
rb->create_numbered_filename(logfilename, HOME_DIR, "test_gfx_log_", ".txt",
|
||||||
2 IF_CNFN_NUM_(, NULL));
|
2 IF_CNFN_NUM_(, NULL));
|
||||||
fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC, 0666);
|
fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC, 0666);
|
||||||
return fd;
|
return fd;
|
||||||
|
|
|
@ -247,7 +247,7 @@ enum plugin_status plugin_start(const void* parameter)
|
||||||
case GREY_OK:
|
case GREY_OK:
|
||||||
|
|
||||||
/* dump result in form suitable for lcdlinear[] */
|
/* dump result in form suitable for lcdlinear[] */
|
||||||
rb->create_numbered_filename(filename, "/", "test_grey_",
|
rb->create_numbered_filename(filename, HOME_DIR, "test_grey_",
|
||||||
".txt", 2 IF_CNFN_NUM_(, NULL));
|
".txt", 2 IF_CNFN_NUM_(, NULL));
|
||||||
fd = rb->open(filename, O_RDWR|O_CREAT|O_TRUNC, 0666);
|
fd = rb->open(filename, O_RDWR|O_CREAT|O_TRUNC, 0666);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#define opendir opendir_android
|
#define opendir opendir_android
|
||||||
#define mkdir mkdir_android
|
#define mkdir mkdir_android
|
||||||
#define rmdir rmdir_android
|
#define rmdir rmdir_android
|
||||||
|
static const char rbhome[] = "/sdcard";
|
||||||
#elif defined(SAMSUNG_YPR0)
|
#elif defined(SAMSUNG_YPR0)
|
||||||
#include "dir-target.h"
|
#include "dir-target.h"
|
||||||
#define opendir opendir_ypr0
|
#define opendir opendir_ypr0
|
||||||
|
@ -159,19 +160,34 @@ static const char* _get_user_file_path(const char *path,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const char* handle_special_dirs(const char* dir, unsigned flags,
|
||||||
|
char *buf, const size_t bufsize)
|
||||||
|
{
|
||||||
|
if (!strncmp(HOME_DIR, dir, HOME_DIR_LEN))
|
||||||
|
{
|
||||||
|
const char *p = dir + HOME_DIR_LEN;
|
||||||
|
while (*p == '/') p++;
|
||||||
|
snprintf(buf, bufsize, "%s/%s", rbhome, p);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
else if (!strncmp(ROCKBOX_DIR, dir, ROCKBOX_DIR_LEN))
|
||||||
|
return _get_user_file_path(dir, flags, buf, bufsize);
|
||||||
|
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
int app_open(const char *name, int o, ...)
|
int app_open(const char *name, int o, ...)
|
||||||
{
|
{
|
||||||
char realpath[MAX_PATH];
|
char realpath[MAX_PATH];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if (!strncmp(ROCKBOX_DIR, name, ROCKBOX_DIR_LEN))
|
|
||||||
{
|
|
||||||
int flags = IS_FILE;
|
int flags = IS_FILE;
|
||||||
if (o & (O_CREAT|O_RDWR|O_TRUNC|O_WRONLY))
|
if (o & (O_CREAT|O_RDWR|O_TRUNC|O_WRONLY))
|
||||||
flags |= NEED_WRITE;
|
flags |= NEED_WRITE;
|
||||||
name = _get_user_file_path(name, flags, realpath, sizeof(realpath));
|
|
||||||
}
|
name = handle_special_dirs(name, flags, realpath, sizeof(realpath));
|
||||||
|
|
||||||
va_start(ap, o);
|
va_start(ap, o);
|
||||||
fd = open(name, o, va_arg(ap, unsigned int));
|
fd = open(name, o, va_arg(ap, unsigned int));
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
@ -187,11 +203,7 @@ int app_creat(const char* name, mode_t mode)
|
||||||
int app_remove(const char *name)
|
int app_remove(const char *name)
|
||||||
{
|
{
|
||||||
char realpath[MAX_PATH];
|
char realpath[MAX_PATH];
|
||||||
const char *fname = name;
|
const char *fname = handle_special_dirs(name, NEED_WRITE, realpath, sizeof(realpath));
|
||||||
if (!strncmp(ROCKBOX_DIR, name, ROCKBOX_DIR_LEN))
|
|
||||||
{
|
|
||||||
fname = _get_user_file_path(name, NEED_WRITE, realpath, sizeof(realpath));
|
|
||||||
}
|
|
||||||
|
|
||||||
return remove(fname);
|
return remove(fname);
|
||||||
}
|
}
|
||||||
|
@ -199,18 +211,10 @@ int app_remove(const char *name)
|
||||||
int app_rename(const char *old, const char *new)
|
int app_rename(const char *old, const char *new)
|
||||||
{
|
{
|
||||||
char realpath_old[MAX_PATH], realpath_new[MAX_PATH];
|
char realpath_old[MAX_PATH], realpath_new[MAX_PATH];
|
||||||
|
const char *final_old, *final_new;
|
||||||
|
|
||||||
const char *final_old = old;
|
final_old = handle_special_dirs(old, NEED_WRITE, realpath_old, sizeof(realpath_old));
|
||||||
if (!strncmp(ROCKBOX_DIR, old, ROCKBOX_DIR_LEN))
|
final_new = handle_special_dirs(new, NEED_WRITE, realpath_new, sizeof(realpath_new));
|
||||||
{
|
|
||||||
final_old = _get_user_file_path(old, NEED_WRITE, realpath_old, sizeof(realpath_old));
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *final_new = new;
|
|
||||||
if (!strncmp(ROCKBOX_DIR, new, ROCKBOX_DIR_LEN))
|
|
||||||
{
|
|
||||||
final_new = _get_user_file_path(new, NEED_WRITE, realpath_new, sizeof(realpath_new));
|
|
||||||
}
|
|
||||||
|
|
||||||
return rename(final_old, final_new);
|
return rename(final_old, final_new);
|
||||||
}
|
}
|
||||||
|
@ -218,33 +222,21 @@ int app_rename(const char *old, const char *new)
|
||||||
DIR *app_opendir(const char *name)
|
DIR *app_opendir(const char *name)
|
||||||
{
|
{
|
||||||
char realpath[MAX_PATH];
|
char realpath[MAX_PATH];
|
||||||
const char *fname = name;
|
const char *fname = handle_special_dirs(name, 0, realpath, sizeof(realpath));
|
||||||
if (!strncmp(ROCKBOX_DIR, name, ROCKBOX_DIR_LEN))
|
|
||||||
{
|
|
||||||
fname = _get_user_file_path(name, 0, realpath, sizeof(realpath));
|
|
||||||
}
|
|
||||||
return opendir(fname);
|
return opendir(fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
int app_mkdir(const char* name)
|
int app_mkdir(const char* name)
|
||||||
{
|
{
|
||||||
char realpath[MAX_PATH];
|
char realpath[MAX_PATH];
|
||||||
const char *fname = name;
|
const char *fname = handle_special_dirs(name, NEED_WRITE, realpath, sizeof(realpath));
|
||||||
if (!strncmp(ROCKBOX_DIR, name, ROCKBOX_DIR_LEN))
|
|
||||||
{
|
|
||||||
fname = _get_user_file_path(name, NEED_WRITE, realpath, sizeof(realpath));
|
|
||||||
}
|
|
||||||
return mkdir(fname);
|
return mkdir(fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
int app_rmdir(const char* name)
|
int app_rmdir(const char* name)
|
||||||
{
|
{
|
||||||
char realpath[MAX_PATH];
|
char realpath[MAX_PATH];
|
||||||
const char *fname = name;
|
const char *fname = handle_special_dirs(name, NEED_WRITE, realpath, sizeof(realpath));
|
||||||
if (!strncmp(ROCKBOX_DIR, name, ROCKBOX_DIR_LEN))
|
|
||||||
{
|
|
||||||
fname = _get_user_file_path(name, NEED_WRITE, realpath, sizeof(realpath));
|
|
||||||
}
|
|
||||||
return rmdir(fname);
|
return rmdir(fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,12 @@
|
||||||
|
|
||||||
#if !defined(APPLICATION) || defined(SAMSUNG_YPR0)
|
#if !defined(APPLICATION) || defined(SAMSUNG_YPR0)
|
||||||
|
|
||||||
|
#ifdef SAMSUNG_YPR0
|
||||||
|
#define HOME_DIR "/mnt/media0"
|
||||||
|
#else
|
||||||
|
#define HOME_DIR "/." /* dot to avoid "//XX", /./X is valid */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* make sure both are the same for native builds */
|
/* make sure both are the same for native builds */
|
||||||
#undef ROCKBOX_LIBRARY_PATH
|
#undef ROCKBOX_LIBRARY_PATH
|
||||||
#define ROCKBOX_LIBRARY_PATH ROCKBOX_DIR
|
#define ROCKBOX_LIBRARY_PATH ROCKBOX_DIR
|
||||||
|
@ -53,12 +59,15 @@
|
||||||
#define PLUGIN_DIR ROCKBOX_DIR "/rocks"
|
#define PLUGIN_DIR ROCKBOX_DIR "/rocks"
|
||||||
#define CODECS_DIR ROCKBOX_DIR "/codecs"
|
#define CODECS_DIR ROCKBOX_DIR "/codecs"
|
||||||
|
|
||||||
#define REC_BASE_DIR "/"
|
#define REC_BASE_DIR HOME_DIR
|
||||||
#define PLAYLIST_CATALOG_DEFAULT_DIR "/Playlists"
|
#define PLAYLIST_CATALOG_DEFAULT_DIR HOME_DIR "/Playlists"
|
||||||
|
|
||||||
#define paths_init()
|
#define paths_init()
|
||||||
|
|
||||||
#else /* application */
|
#else /* APPLICATION */
|
||||||
|
|
||||||
|
#define HOME_DIR "<HOME>" /* replaced at runtime */
|
||||||
|
#define HOME_DIR_LEN (sizeof(HOME_DIR)-1)
|
||||||
|
|
||||||
#define PLUGIN_DIR ROCKBOX_LIBRARY_PATH "/rockbox/rocks"
|
#define PLUGIN_DIR ROCKBOX_LIBRARY_PATH "/rockbox/rocks"
|
||||||
#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
|
#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
|
||||||
|
@ -67,12 +76,12 @@
|
||||||
#define CODECS_DIR ROCKBOX_LIBRARY_PATH "/rockbox/codecs"
|
#define CODECS_DIR ROCKBOX_LIBRARY_PATH "/rockbox/codecs"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define REC_BASE_DIR ROCKBOX_DIR "/"
|
#define REC_BASE_DIR HOME_DIR
|
||||||
#define PLAYLIST_CATALOG_DEFAULT_DIR ROCKBOX_DIR "/Playlists"
|
#define PLAYLIST_CATALOG_DEFAULT_DIR HOME_DIR "Playlists"
|
||||||
|
|
||||||
extern void paths_init(void);
|
extern void paths_init(void);
|
||||||
|
|
||||||
#endif /* APPLICATION */
|
#endif /* !APPLICATION || SAMSUNG_YPR0 */
|
||||||
|
|
||||||
#define LANG_DIR ROCKBOX_DIR "/langs"
|
#define LANG_DIR ROCKBOX_DIR "/langs"
|
||||||
|
|
||||||
|
@ -82,7 +91,7 @@ extern void paths_init(void);
|
||||||
#define VIEWERS_DIR PLUGIN_DIR "/viewers"
|
#define VIEWERS_DIR PLUGIN_DIR "/viewers"
|
||||||
|
|
||||||
#if defined(APPLICATION) && !defined(SAMSUNG_YPR0)
|
#if defined(APPLICATION) && !defined(SAMSUNG_YPR0)
|
||||||
#define PLUGIN_DATA_DIR "/.rockbox/rocks.data"
|
#define PLUGIN_DATA_DIR ROCKBOX_DIR "/rocks.data"
|
||||||
#define PLUGIN_GAMES_DATA_DIR PLUGIN_DATA_DIR
|
#define PLUGIN_GAMES_DATA_DIR PLUGIN_DATA_DIR
|
||||||
#define PLUGIN_APPS_DATA_DIR PLUGIN_DATA_DIR
|
#define PLUGIN_APPS_DATA_DIR PLUGIN_DATA_DIR
|
||||||
#define PLUGIN_DEMOS_DATA_DIR PLUGIN_DATA_DIR
|
#define PLUGIN_DEMOS_DATA_DIR PLUGIN_DATA_DIR
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "general.h"
|
#include "general.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "dir.h"
|
#include "dir.h"
|
||||||
|
#include "rbpaths.h"
|
||||||
#include "limits.h"
|
#include "limits.h"
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
#include "string-extra.h"
|
#include "string-extra.h"
|
||||||
|
@ -126,7 +127,7 @@ char *create_numbered_filename(char *buffer, const char *path,
|
||||||
/* automatic numbering */
|
/* automatic numbering */
|
||||||
max_num = 0;
|
max_num = 0;
|
||||||
|
|
||||||
dir = opendir(pathlen ? buffer : "/");
|
dir = opendir(pathlen ? buffer : HOME_DIR);
|
||||||
if (!dir)
|
if (!dir)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue