summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/filetypes.c8
-rw-r--r--apps/gui/icon.c7
-rw-r--r--apps/gui/skin_engine/skin_backdrops.c14
-rw-r--r--apps/gui/skin_engine/skin_engine.c6
-rw-r--r--apps/gui/skin_engine/skin_fonts.c4
-rw-r--r--apps/gui/skin_engine/skin_parser.c3
-rw-r--r--apps/main.c4
-rw-r--r--apps/menus/theme_menu.c4
-rw-r--r--apps/playlist.c10
-rw-r--r--apps/playlist_catalog.c8
-rw-r--r--apps/plugin.c6
-rw-r--r--apps/settings.c36
-rw-r--r--apps/tagcache.c145
-rw-r--r--apps/tree.c3
-rw-r--r--firmware/common/dircache.c11
-rw-r--r--firmware/common/rbpaths.c166
-rw-r--r--firmware/export/rbpaths.h35
-rw-r--r--firmware/font.c10
-rw-r--r--firmware/include/dir.h7
-rw-r--r--firmware/include/dir_uncached.h33
-rw-r--r--firmware/include/file.h46
-rw-r--r--firmware/load_code.c6
-rw-r--r--firmware/target/hosted/android/dir-target.h21
-rw-r--r--firmware/target/hosted/android/fs-android.c1
-rw-r--r--uisimulator/common/io.c1
25 files changed, 309 insertions, 286 deletions
diff --git a/apps/filetypes.c b/apps/filetypes.c
index f23026ea69..481c0df6de 100644
--- a/apps/filetypes.c
+++ b/apps/filetypes.c
@@ -219,15 +219,14 @@ static void read_config(const char* config_file);
* load a colors file from a theme with:
* filetype colours: filename.colours */
void read_color_theme_file(void) {
- char buffer[MAX_PATH], dir[MAX_PATH];
+ char buffer[MAX_PATH];
int fd;
char *ext, *color;
int i;
for (i = 0; i < MAX_FILETYPES+1; i++) {
custom_colors[i] = -1;
}
- snprintf(buffer, MAX_PATH, "%s/%s.colours",
- get_user_file_path(THEME_DIR, 0, dir, sizeof(dir)),
+ snprintf(buffer, MAX_PATH, THEME_DIR "/%s.colours",
global_settings.colors_file);
fd = open(buffer, O_RDONLY);
if (fd < 0)
@@ -300,7 +299,6 @@ void read_viewer_theme_file(void)
void filetype_init(void)
{
- char path[MAX_PATH];
/* set the directory item first */
filetypes[0].extension = NULL;
filetypes[0].plugin = NULL;
@@ -310,7 +308,7 @@ void filetype_init(void)
viewer_count = 0;
filetype_count = 1;
read_builtin_types();
- read_config(get_user_file_path(VIEWERS_CONFIG, IS_FILE, path, sizeof(path)));
+ read_config(VIEWERS_CONFIG);
#ifdef HAVE_LCD_BITMAP
read_viewer_theme_file();
#endif
diff --git a/apps/gui/icon.c b/apps/gui/icon.c
index c4581e031f..628196a98f 100644
--- a/apps/gui/icon.c
+++ b/apps/gui/icon.c
@@ -228,12 +228,9 @@ static void load_icons(const char* filename, enum Iconset iconset)
if (filename[0] && filename[0] != '-')
{
char path[MAX_PATH];
- char temp[MAX_PATH];
- const char * fname;
- snprintf(path, sizeof(path), "%s/%s.bmp", ICON_DIR, filename);
- fname = get_user_file_path(path, IS_FILE, temp, sizeof(temp));
- size_read = read_bmp_file(fname, bmp, IMG_BUFSIZE, bmpformat, NULL);
+ snprintf(path, sizeof(path), ICON_DIR "/%s.bmp", filename);
+ size_read = read_bmp_file(path, bmp, IMG_BUFSIZE, bmpformat, NULL);
if (size_read > 0)
{
*loaded_ok = true;
diff --git a/apps/gui/skin_engine/skin_backdrops.c b/apps/gui/skin_engine/skin_backdrops.c
index e337774994..3e04beaae0 100644
--- a/apps/gui/skin_engine/skin_backdrops.c
+++ b/apps/gui/skin_engine/skin_backdrops.c
@@ -54,7 +54,6 @@ void skin_backdrop_init(void)
int skin_backdrop_assign(char* backdrop, char *bmpdir,
enum screen_type screen)
{
- char dir[MAX_PATH];
char filename[MAX_PATH];
int i, free = -1;
if (!backdrop)
@@ -68,8 +67,7 @@ int skin_backdrop_assign(char* backdrop, char *bmpdir,
}
else
{
- const char *bd_dir = get_user_file_path(bmpdir, 0, dir, sizeof(dir));
- get_image_filename(backdrop, bd_dir, filename, sizeof(filename));
+ get_image_filename(backdrop, bmpdir, filename, sizeof(filename));
}
for (i=0; i<NB_BDROPS; i++)
{
@@ -115,12 +113,9 @@ bool skin_backdrops_preload(void)
if (screen == SCREEN_MAIN && global_settings.backdrop_file[0] &&
global_settings.backdrop_file[0] != '-' && filename[0] == '-')
{
- char dir[MAX_PATH];
char* temp = filename+2; /* slightly hacky to get a buffer */
size_t size = sizeof(backdrops[i].name) - 2;
- snprintf(temp, size, "%s/%s.bmp",
- get_user_file_path(BACKDROP_DIR, 0, dir, sizeof(dir)),
- global_settings.backdrop_file);
+ snprintf(temp, size, BACKDROP_DIR "/%s.bmp", global_settings.backdrop_file);
filename = temp;
}
if (*filename && *filename != '-')
@@ -161,7 +156,7 @@ void skin_backdrop_unload(int backdrop_id)
void skin_backdrop_load_setting(void)
{
int i;
- char filename[MAX_PATH], dir[MAX_PATH];
+ char filename[MAX_PATH];
for(i=0;i<SKINNABLE_SCREENS_COUNT*NB_SCREENS;i++)
{
if (backdrops[i].name[0] == '-' && backdrops[i].screen == SCREEN_MAIN)
@@ -171,8 +166,7 @@ void skin_backdrop_load_setting(void)
{
if (!backdrops[i].buffer)
backdrops[i].buffer = (char*)skin_buffer_alloc(LCD_BACKDROP_BYTES);
- snprintf(filename, sizeof filename, "%s/%s.bmp",
- get_user_file_path(BACKDROP_DIR, 0, dir, sizeof(dir)),
+ snprintf(filename, sizeof filename, BACKDROP_DIR "/%s.bmp",
global_settings.backdrop_file);
bool loaded = backdrops[i].buffer &&
screens[SCREEN_MAIN].backdrop_load(filename,
diff --git a/apps/gui/skin_engine/skin_engine.c b/apps/gui/skin_engine/skin_engine.c
index 25baeb2c3c..fbedbb96fd 100644
--- a/apps/gui/skin_engine/skin_engine.c
+++ b/apps/gui/skin_engine/skin_engine.c
@@ -155,7 +155,7 @@ struct gui_wps *skin_get_gwps(enum skinnable_screens skin, enum screen_type scre
{
if (!loading_a_sbs && skins[skin][screen].data.wps_loaded == false)
{
- char buf[MAX_PATH*2], path[MAX_PATH];
+ char buf[MAX_PATH*2];
char *setting = NULL, *ext = NULL;
switch (skin)
{
@@ -226,9 +226,7 @@ struct gui_wps *skin_get_gwps(enum skinnable_screens skin, enum screen_type scre
buf[0] = '\0'; /* force it to reload the default */
if (strcmp(setting, "rockbox_failsafe"))
{
- snprintf(buf, sizeof buf, "%s/%s.%s",
- get_user_file_path(WPS_DIR, false, path, sizeof(path)),
- setting, ext);
+ snprintf(buf, sizeof buf, WPS_DIR "/%s.%s", setting, ext);
}
cpu_boost(true);
skin_load(skin, screen, buf, true);
diff --git a/apps/gui/skin_engine/skin_fonts.c b/apps/gui/skin_engine/skin_fonts.c
index e5081e8cd9..23255aa8cc 100644
--- a/apps/gui/skin_engine/skin_fonts.c
+++ b/apps/gui/skin_engine/skin_fonts.c
@@ -64,7 +64,6 @@ int skin_font_load(char* font_name, int glyphs)
struct font *pf;
struct skin_font_info *font = NULL;
char filename[MAX_PATH];
- char tmp[MAX_PATH];
if (!strcmp(font_name, global_settings.font_file))
return FONT_UI;
@@ -72,8 +71,7 @@ int skin_font_load(char* font_name, int glyphs)
if (!strcmp(font_name, global_settings.remote_font_file))
return FONT_UI_REMOTE;
#endif
- snprintf(tmp, MAX_PATH, FONT_DIR "/%s.fnt", font_name);
- get_user_file_path(tmp, FORCE_BUFFER_COPY, filename, sizeof(filename));
+ snprintf(filename, MAX_PATH, FONT_DIR "/%s.fnt", font_name);
for(i=0;i<MAXUSERFONTS;i++)
{
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 4da13842e4..f292ff3946 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -1646,8 +1646,7 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
strlcpy(bmpdir, buf, dot - buf + 1);
}
else
- { /* fall back to backdrop dir for built-in themes */
- /* no get_user_file_path(), assuming we ship bmps for built-in themes */
+ {
snprintf(bmpdir, MAX_PATH, "%s", BACKDROP_DIR);
}
/* load the bitmaps that were found by the parsing */
diff --git a/apps/main.c b/apps/main.c
index 950168d8ed..7af4cca37e 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -172,13 +172,13 @@ int main(void)
#ifdef AUTOROCK
{
char filename[MAX_PATH];
- const char *file = get_user_file_path(
+ const char *file =
#ifdef APPLICATION
ROCKBOX_DIR
#else
PLUGIN_APPS_DIR
#endif
- "/autostart.rock", NEED_WRITE|IS_FILE, filename, sizeof(filename));
+ "/autostart.rock";
if(file_exists(file)) /* no complaint if it doesn't exist */
{
plugin_load(file, NULL); /* start if it does */
diff --git a/apps/menus/theme_menu.c b/apps/menus/theme_menu.c
index 66274e2e18..983eca9445 100644
--- a/apps/menus/theme_menu.c
+++ b/apps/menus/theme_menu.c
@@ -246,11 +246,9 @@ static struct browse_folder_info themes = {THEME_DIR, SHOW_CFG};
int browse_folder(void *param)
{
- char path[MAX_PATH];
const struct browse_folder_info *info =
(const struct browse_folder_info*)param;
- return rockbox_browse(get_user_file_path(info->dir, 0, path, sizeof(path)),
- info->show_options);
+ return rockbox_browse(info->dir, info->show_options);
}
#ifdef HAVE_LCD_BITMAP
diff --git a/apps/playlist.c b/apps/playlist.c
index f56603749a..41d6ae5ed7 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -1439,12 +1439,7 @@ static int get_next_dir(char *dir, bool is_forward, bool recursion)
/* process random folder advance */
if (global_settings.next_folder == FOLDER_ADVANCE_RANDOM)
{
- char folder_advance_list[MAX_PATH];
- get_user_file_path(ROCKBOX_DIR, FORCE_BUFFER_COPY,
- folder_advance_list, sizeof(folder_advance_list));
- strlcat(folder_advance_list, "/folder_advance_list.dat",
- sizeof(folder_advance_list));
- int fd = open(folder_advance_list, O_RDONLY);
+ int fd = open(ROCKBOX_DIR "/folder_advance_list.dat", O_RDONLY);
if (fd >= 0)
{
char buffer[MAX_PATH];
@@ -1914,8 +1909,7 @@ void playlist_init(void)
struct playlist_info* playlist = &current_playlist;
playlist->current = true;
- get_user_file_path(PLAYLIST_CONTROL_FILE, IS_FILE|NEED_WRITE|FORCE_BUFFER_COPY,
- playlist->control_filename,
+ strlcpy(playlist->control_filename, PLAYLIST_CONTROL_FILE,
sizeof(playlist->control_filename));
playlist->fd = -1;
playlist->control_fd = -1;
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c
index 5f9f46728a..ff69b28263 100644
--- a/apps/playlist_catalog.c
+++ b/apps/playlist_catalog.c
@@ -81,11 +81,9 @@ static int initialize_catalog(void)
/* fall back to default directory if no or invalid config */
if (default_dir)
{
- const char *dir = get_user_file_path(PLAYLIST_CATALOG_DEFAULT_DIR,
- FORCE_BUFFER_COPY|NEED_WRITE,
- playlist_dir, sizeof(playlist_dir));
- if (!dir_exists(dir))
- mkdir(dir);
+ strcpy(playlist_dir, PLAYLIST_CATALOG_DEFAULT_DIR);
+ if (!dir_exists(playlist_dir))
+ mkdir(playlist_dir);
}
playlist_dir_length = strlen(playlist_dir);
diff --git a/apps/plugin.c b/apps/plugin.c
index 316c7c6b5d..f28593ec4e 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -314,11 +314,11 @@ static const struct plugin_api rockbox_api = {
#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
(creat_func)creat_wrapper,
#else
- (creat_func)PREFIX(creat),
+ (creat_func)creat,
#endif
(write_func)PREFIX(write),
- PREFIX(remove),
- PREFIX(rename),
+ remove,
+ rename,
PREFIX(ftruncate),
PREFIX(filesize),
fdprintf,
diff --git a/apps/settings.c b/apps/settings.c
index 85b0489c09..848c7c14f2 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -118,9 +118,7 @@ static bool read_nvram_data(char* buf, int max_len)
unsigned crc32 = 0xffffffff;
int var_count = 0, i = 0, buf_pos = 0;
#ifndef HAVE_RTC_RAM
- char path[MAX_PATH];
- int fd = open(get_user_file_path(NVRAM_FILE, IS_FILE|NEED_WRITE,
- path, sizeof(path)), O_RDONLY);
+ int fd = open(NVRAM_FILE, O_RDONLY);
int bytes;
if (fd < 0)
return false;
@@ -174,7 +172,6 @@ static bool write_nvram_data(char* buf, int max_len)
char var_count = 0;
#ifndef HAVE_RTC_RAM
int fd;
- char path[MAX_PATH];
#endif
memset(buf,0,max_len);
/* magic, version */
@@ -198,8 +195,7 @@ static bool write_nvram_data(char* buf, int max_len)
max_len-NVRAM_DATA_START-1,0xffffffff);
memcpy(&buf[4],&crc32,4);
#ifndef HAVE_RTC_RAM
- fd = open(get_user_file_path(NVRAM_FILE, IS_FILE|NEED_WRITE,
- path, sizeof(path)),O_CREAT|O_TRUNC|O_WRONLY, 0666);
+ fd = open(NVRAM_FILE,O_CREAT|O_TRUNC|O_WRONLY, 0666);
if (fd >= 0)
{
int len = write(fd,buf,max_len);
@@ -230,12 +226,8 @@ void settings_load(int which)
read_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
if (which&SETTINGS_HD)
{
- const char *file;
- char path[MAX_PATH];
- file = get_user_file_path(CONFIGFILE, IS_FILE|NEED_WRITE, path, sizeof(path));
- settings_load_config(file, false);
- file = get_user_file_path(FIXEDSETTINGSFILE, IS_FILE, path, sizeof(path));
- settings_load_config(file, false);
+ settings_load_config(CONFIGFILE, false);
+ settings_load_config(FIXEDSETTINGSFILE, false);
}
}
@@ -596,11 +588,8 @@ static void flush_global_status_callback(void *data)
static void flush_config_block_callback(void *data)
{
(void)data;
- char path[MAX_PATH];
write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
- settings_write_config(
- get_user_file_path(CONFIGFILE, IS_FILE|NEED_WRITE, path, sizeof(path)),
- SETTINGS_SAVE_CHANGED);
+ settings_write_config(CONFIGFILE, SETTINGS_SAVE_CHANGED);
}
/*
@@ -644,7 +633,7 @@ int settings_save(void)
bool settings_save_config(int options)
{
- char filename[MAX_PATH], path[MAX_PATH];
+ char filename[MAX_PATH];
const char *folder, *namebase;
switch (options)
{
@@ -673,8 +662,6 @@ bool settings_save_config(int options)
namebase = "config";
break;
}
-
- folder = get_user_file_path(folder, NEED_WRITE, path, sizeof(path));
create_numbered_filename(filename, folder, namebase, ".cfg", 2
IF_CNFN_NUM_(, NULL));
@@ -884,13 +871,11 @@ void settings_apply(bool read_disk)
{
char buf[MAX_PATH];
#ifdef HAVE_LCD_BITMAP
- char dir[MAX_PATH];
- const char *font_path = get_user_file_path(FONT_DIR, 0, dir, sizeof(dir));
/* fonts need to be loaded before the WPS */
if (global_settings.font_file[0]
&& global_settings.font_file[0] != '-') {
- snprintf(buf, sizeof buf, "%s/%s.fnt", font_path,
+ snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
global_settings.font_file);
CHART2(">font_load ", global_settings.font_file);
rc = font_load(NULL, buf);
@@ -903,7 +888,7 @@ void settings_apply(bool read_disk)
#ifdef HAVE_REMOTE_LCD
if ( global_settings.remote_font_file[0]
&& global_settings.remote_font_file[0] != '-') {
- snprintf(buf, sizeof buf, "%s/%s.fnt", font_path,
+ snprintf(buf, sizeof buf, FONT_DIR "%s.fnt",
global_settings.remote_font_file);
CHART2(">font_load_remoteui ", global_settings.remote_font_file);
rc = font_load_remoteui(buf);
@@ -915,8 +900,7 @@ void settings_apply(bool read_disk)
font_load_remoteui(NULL);
#endif
if ( global_settings.kbd_file[0]) {
- snprintf(buf, sizeof buf, "%s/%s.kbd",
- get_user_file_path(ROCKBOX_DIR, 0, dir, sizeof(dir)),
+ snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd",
global_settings.kbd_file);
CHART(">load_kbd");
load_kbd(buf);
@@ -925,8 +909,6 @@ void settings_apply(bool read_disk)
else
load_kbd(NULL);
#endif /* HAVE_LCD_BITMAP */
- /* no get_user_file_path() here because we don't really support
- * langs that don't come with rockbox */
if ( global_settings.lang_file[0]) {
snprintf(buf, sizeof buf, LANG_DIR "/%s.lng",
global_settings.lang_file);
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 679d7cbe79..5b175c4b20 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -73,9 +73,9 @@
#include "buffer.h"
#include "crc32.h"
#include "misc.h"
-#include "filefuncs.h"
#include "settings.h"
#include "dir.h"
+#include "filefuncs.h"
#include "structec.h"
#ifndef __PCTOOL__
@@ -293,17 +293,15 @@ static bool is_dircache_intact(void)
static int open_tag_fd(struct tagcache_header *hdr, int tag, bool write)
{
int fd;
- char buf[MAX_PATH], path[MAX_PATH];
- const char * file;
+ char buf[MAX_PATH];
int rc;
if (TAGCACHE_IS_NUMERIC(tag) || tag < 0 || tag >= TAG_COUNT)
return -1;
snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, tag);
- file = get_user_file_path(buf, IS_FILE | NEED_WRITE, path, sizeof(path));
- fd = open(file, write ? O_RDWR : O_RDONLY);
+ fd = open(buf, write ? O_RDWR : O_RDONLY);
if (fd < 0)
{
logf("tag file open failed: tag=%d write=%d file=%s", tag, write, buf);
@@ -328,12 +326,8 @@ static int open_master_fd(struct master_header *hdr, bool write)
{
int fd;
int rc;
- char path[MAX_PATH];
- fd = open(get_user_file_path(TAGCACHE_FILE_MASTER,
- IS_FILE|NEED_WRITE,
- path, sizeof(path)),
- write ? O_RDWR : O_RDONLY);
+ fd = open(TAGCACHE_FILE_MASTER, write ? O_RDWR : O_RDONLY);
if (fd < 0)
{
logf("master file open failed for R/W");
@@ -675,12 +669,10 @@ static bool open_files(struct tagcache_search *tcs, int tag)
{
if (tcs->idxfd[tag] < 0)
{
- char fn[MAX_PATH], path[MAX_PATH];
- const char *file;
+ char fn[MAX_PATH];
snprintf(fn, sizeof fn, TAGCACHE_FILE_INDEX, tag);
- file = get_user_file_path(fn, IS_FILE | NEED_WRITE, path, sizeof(path));
- tcs->idxfd[tag] = open(file, O_RDONLY);
+ tcs->idxfd[tag] = open(fn, O_RDONLY);
}
if (tcs->idxfd[tag] < 0)
@@ -1218,17 +1210,14 @@ static void remove_files(void)
tc_stat.ready = false;
tc_stat.ramcache = false;
tc_stat.econ = false;
- remove(get_user_file_path(TAGCACHE_FILE_MASTER, NEED_WRITE|IS_FILE,
- buf, sizeof(buf)));
+ remove(TAGCACHE_FILE_MASTER);
for (i = 0; i < TAG_COUNT; i++)
{
- char buf2[MAX_PATH];
if (TAGCACHE_IS_NUMERIC(i))
continue;
-
- /* database_%d.tcd -> database_0.tcd */
+
snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, i);
- remove(get_user_file_path(buf, NEED_WRITE | IS_FILE, buf2, sizeof(buf2)));
+ remove(buf);
}
}
@@ -1379,11 +1368,10 @@ bool tagcache_search_add_clause(struct tagcache_search *tcs,
if (!TAGCACHE_IS_NUMERIC(clause->tag) && tcs->idxfd[clause->tag] < 0)
{
- char buf[MAX_PATH], path[MAX_PATH];
- const char *file;
- snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, clause->tag);
- file = get_user_file_path(buf, IS_FILE | NEED_WRITE, path, sizeof(path));
- tcs->idxfd[clause->tag] = open(file, O_RDONLY);
+ char buf[MAX_PATH];
+
+ snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, clause->tag);
+ tcs->idxfd[clause->tag] = open(buf, O_RDONLY);
}
tcs->clause[tcs->clause_count] = clause;
@@ -2407,8 +2395,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
struct master_header tcmh;
struct index_entry idxbuf[IDX_BUF_DEPTH];
int idxbuf_pos;
- char buf[TAG_MAXLEN+32], path[MAX_PATH];
- const char *file;
+ char buf[TAG_MAXLEN+32];
int fd = -1, masterfd;
bool error = false;
int init;
@@ -2556,8 +2543,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
* anything whether the index type is sorted or not.
*/
snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, index_type);
- file = get_user_file_path(buf, IS_FILE | NEED_WRITE, path, sizeof(path));
- fd = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+ fd = open(buf, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd < 0)
{
logf("%s open fail", buf);
@@ -2577,21 +2563,18 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
}
}
- file = get_user_file_path(TAGCACHE_FILE_MASTER,
- IS_FILE|NEED_WRITE,
- buf, sizeof(buf));
/* Loading the tag lookup file as "master file". */
logf("Loading index file");
- masterfd = open(file, O_RDWR);
+ masterfd = open(TAGCACHE_FILE_MASTER, O_RDWR);
if (masterfd < 0)
{
logf("Creating new DB");
- masterfd = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+ masterfd = open(TAGCACHE_FILE_MASTER, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (masterfd < 0)
{
- logf("Failure to create index file (%s)", file);
+ logf("Failure to create index file (%s)", TAGCACHE_FILE_MASTER);
close(fd);
return -2;
}
@@ -2899,8 +2882,6 @@ static bool commit(void)
{
struct tagcache_header tch;
struct master_header tcmh;
- char path[MAX_PATH];
- const char *file;
int i, len, rc;
int tmpfd;
int masterfd;
@@ -2914,10 +2895,7 @@ static bool commit(void)
while (write_lock)
sleep(1);
- file = get_user_file_path(TAGCACHE_FILE_TEMP,
- IS_FILE|NEED_WRITE, path, sizeof(path));
-
- tmpfd = open(file, O_RDONLY);
+ tmpfd = open(TAGCACHE_FILE_TEMP, O_RDONLY);
if (tmpfd < 0)
{
logf("nothing to commit");
@@ -2933,7 +2911,7 @@ static bool commit(void)
{
logf("incorrect tmpheader");
close(tmpfd);
- remove(file);
+ remove(TAGCACHE_FILE_TEMP);
return false;
}
@@ -2941,7 +2919,7 @@ static bool commit(void)
{
logf("nothing to commit");
close(tmpfd);
- remove(file);
+ remove(TAGCACHE_FILE_TEMP);
return true;
}
@@ -2949,8 +2927,7 @@ static bool commit(void)
tc_stat.ready = check_all_headers();
#ifdef HAVE_EEPROM_SETTINGS
- remove(get_user_file_path(TAGCACHE_STATEFILE, IS_FILE | NEED_WRITE,
- path, sizeof(path)));
+ remove(TAGCACHE_STATEFILE);
#endif
/* At first be sure to unload the ramcache! */
@@ -3040,7 +3017,7 @@ static bool commit(void)
}
close(tmpfd);
- remove(file);
+ remove(TAGCACHE_FILE_TEMP);
tc_stat.commit_step = 0;
@@ -3458,18 +3435,15 @@ bool tagcache_import_changelog(void)
struct tagcache_header tch;
int clfd;
long masterfd;
- char buf[MAX(MAX_PATH, 2048)];
- const char *file;
+ char buf[2048];
if (!tc_stat.ready)
return false;
while (read_lock)
sleep(1);
-
- file = get_user_file_path(TAGCACHE_FILE_CHANGELOG,
- IS_FILE|NEED_WRITE, buf, sizeof(buf));
- clfd = open(file, O_RDONLY);
+
+ clfd = open(TAGCACHE_FILE_CHANGELOG, O_RDONLY);
if (clfd < 0)
{
logf("failure to open changelog");
@@ -3511,8 +3485,7 @@ bool tagcache_create_changelog(struct tagcache_search *tcs)
{
struct master_header myhdr;
struct index_entry idx;
- const char *file;
- char buf[MAX(TAG_MAXLEN+32, MAX_PATH)];
+ char buf[TAG_MAXLEN+32];
char temp[32];
int clfd;
int i, j;
@@ -3524,9 +3497,7 @@ bool tagcache_create_changelog(struct tagcache_search *tcs)
return false;
/* Initialize the changelog */
- file = get_user_file_path(TAGCACHE_FILE_CHANGELOG, IS_FILE | NEED_WRITE,
- buf, sizeof(buf));
- clfd = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+ clfd = open(TAGCACHE_FILE_CHANGELOG, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (clfd < 0)
{
logf("failure to open changelog");
@@ -3844,15 +3815,11 @@ static bool allocate_tagcache(void)
static bool tagcache_dumpload(void)
{
struct statefile_header shdr;
- char path[MAX_PATH];
- const char *file;
int fd, rc;
long offpos;
int i;
-
- file = get_user_file_path(TAGCACHE_STATEFILE, IS_FILE | NEED_WRITE,
- path, sizeof(path));
- fd = open(file, O_RDONLY);
+
+ fd = open(TAGCACHE_STATEFILE, O_RDONLY);
if (fd < 0)
{
logf("no tagcache statedump");
@@ -3898,16 +3865,12 @@ static bool tagcache_dumpload(void)
static bool tagcache_dumpsave(void)
{
struct statefile_header shdr;
- char path[MAX_PATH];
- const char *file;
int fd;
if (!tc_stat.ramcache)
return false;
- file = get_user_file_path(TAGCACHE_STATEFILE, IS_FILE | NEED_WRITE,
- path, sizeof(path));
- fd = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+ fd = open(TAGCACHE_STATEFILE, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd < 0)
{
logf("failed to create a statedump");
@@ -3933,8 +3896,7 @@ static bool load_tagcache(void)
long bytesleft = tc_stat.ramcache_allocated;
struct index_entry *idx;
int rc, fd;
- char *p, path[MAX_PATH];
- const char *file;
+ char *p;
int i, tag;
# ifdef HAVE_DIRCACHE
@@ -3945,11 +3907,8 @@ static bool load_tagcache(void)
# endif
logf("loading tagcache to ram...");
-
- file = get_user_file_path(TAGCACHE_FILE_MASTER,
- IS_FILE|NEED_WRITE,
- path, sizeof(path));
- fd = open(file, O_RDONLY);
+
+ fd = open(TAGCACHE_FILE_MASTER, O_RDONLY);
if (fd < 0)
{
logf("tagcache open failed");
@@ -4159,14 +4118,12 @@ static bool load_tagcache(void)
static bool check_deleted_files(void)
{
int fd;
- char buf[TAG_MAXLEN+32], path[MAX_PATH];
- const char *file;
+ char buf[TAG_MAXLEN+32];
struct tagfile_entry tfe;
logf("reverse scan...");
snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, tag_filename);
- file = get_user_file_path(buf, IS_FILE | NEED_WRITE, path, sizeof(path));
- fd = open(file, O_RDONLY);
+ fd = open(buf, O_RDONLY);
if (fd < 0)
{
@@ -4326,8 +4283,6 @@ void tagcache_build(const char *path)
{
struct tagcache_header header;
bool ret;
- char buf[MAX_PATH];
- const char *file;
curpath[0] = '\0';
data_size = 0;
@@ -4340,21 +4295,19 @@ void tagcache_build(const char *path)
#endif
logf("updating tagcache");
-
- file = get_user_file_path(TAGCACHE_FILE_TEMP,
- IS_FILE|NEED_WRITE, buf, sizeof(buf));
-
- if (file_exists(file))
+ cachefd = open(TAGCACHE_FILE_TEMP, O_RDONLY);
+ if (cachefd >= 0)
{
logf("skipping, cache already waiting for commit");
+ close(cachefd);
return ;
}
- cachefd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ cachefd = open(TAGCACHE_FILE_TEMP, O_RDWR | O_CREAT | O_TRUNC, 0666);
if (cachefd < 0)
{
- logf("master file open failed: %s", file);
+ logf("master file open failed: %s", TAGCACHE_FILE_TEMP);
return ;
}
@@ -4398,7 +4351,7 @@ void tagcache_build(const char *path)
#endif
if (commit())
{
- remove(file);
+ remove(TAGCACHE_FILE_TEMP);
logf("tagcache built!");
}
#ifdef __PCTOOL__
@@ -4443,12 +4396,7 @@ void tagcache_unload_ramcache(void)
{
tc_stat.ramcache = false;
/* Just to make sure there is no statefile present. */
-
-#if 0
- char path[MAX_PATH];
- remove(get_user_file_path(TAGCACHE_STATEFILE, IS_FILE | NEED_WRITE,
- path, sizeof(path)));
-#endif
+ // remove(TAGCACHE_STATEFILE);
}
#endif
@@ -4457,7 +4405,6 @@ static void tagcache_thread(void)
{
struct queue_event ev;
bool check_done = false;
- char path[MAX_PATH];
/* If the previous cache build/update was interrupted, commit
* the changes first in foreground. */
@@ -4474,8 +4421,7 @@ static void tagcache_thread(void)
check_done = tagcache_dumpload();
}
- remove(get_user_file_path(TAGCACHE_STATEFILE, IS_FILE | NEED_WRITE,
- path, sizeof(path)));
+ remove(TAGCACHE_STATEFILE);
# endif
/* Allocate space for the tagcache if found on disk. */
@@ -4508,8 +4454,7 @@ static void tagcache_thread(void)
case Q_REBUILD:
remove_files();
- remove(get_user_file_path(TAGCACHE_FILE_TEMP,
- IS_FILE|NEED_WRITE, path, sizeof(path)));
+ remove(TAGCACHE_FILE_TEMP);
tagcache_build("/");
break;
diff --git a/apps/tree.c b/apps/tree.c
index 86238c50d9..98880f001a 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -261,8 +261,7 @@ static int tree_voice_cb(int selected_item, void * data)
bool check_rockboxdir(void)
{
- char path[MAX_PATH];
- if(!dir_exists(get_user_file_path(ROCKBOX_DIR, 0, path, sizeof(path))))
+ if(!dir_exists(ROCKBOX_DIR))
{ /* No need to localise this message.
If .rockbox is missing, it wouldn't work anyway */
int i;
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index 509743bdbb..e8a5e7cbb1 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -89,13 +89,10 @@ static int fdbind_idx = 0;
*/
static int open_dircache_file(unsigned flags, int permissions)
{
- char path[MAX_PATH];
- const char *file = get_user_file_path(DIRCACHE_FILE, IS_FILE|NEED_WRITE,
- path, sizeof(path));
if (permissions != 0)
- return open(file, flags, permissions);
+ return open(DIRCACHE_FILE, flags, permissions);
- return open(file, flags);
+ return open(DIRCACHE_FILE, flags);
}
/**
@@ -103,9 +100,7 @@ static int open_dircache_file(unsigned flags, int permissions)
*/
static int remove_dircache_file(void)
{
- char path[MAX_PATH];
- return remove(get_user_file_path(DIRCACHE_FILE, IS_FILE|NEED_WRITE,
- path, sizeof(path)));
+ return remove(DIRCACHE_FILE);
}
#endif
/**
diff --git a/firmware/common/rbpaths.c b/firmware/common/rbpaths.c
index b63586c9f4..50d6ccf6ec 100644
--- a/firmware/common/rbpaths.c
+++ b/firmware/common/rbpaths.c
@@ -22,13 +22,47 @@
#include <stdio.h> /* snprintf */
#include <stdlib.h>
+#include <stdarg.h>
#include "rbpaths.h"
#include "file.h" /* MAX_PATH */
-#include "dir.h"
#include "gcc_extensions.h"
#include "string-extra.h"
#include "filefuncs.h"
+#undef open
+#undef creat
+#undef remove
+#undef rename
+#undef opendir
+#undef mkdir
+#undef rmdir
+
+#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
+#include "dir-target.h"
+#define opendir opendir_android
+#define mkdir mkdir_android
+#define rmdir rmdir_android
+#elif (CONFIG_PLATFORM & PLATFORM_SDL)
+#define open sim_open
+#define remove sim_remove
+#define rename sim_rename
+#define opendir sim_opendir
+#define mkdir sim_mkdir
+#define rmdir sim_rmdir
+extern int sim_open(const char* name, int o, ...);
+extern int sim_remove(const char* name);
+extern int sim_rename(const char* old, const char* new);
+extern DIR* sim_opendir(const char* name);
+extern int sim_mkdir(const char* name);
+extern int sim_rmdir(const char* name);
+#endif
+
+/* 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)
void paths_init(void)
{
@@ -42,14 +76,28 @@ void paths_init(void)
#endif
}
-const char* get_user_file_path(const char *path,
- unsigned flags,
- char* buf,
- const size_t bufsize)
+static bool try_path(const char* filename, unsigned flags)
+{
+ if (flags & IS_FILE)
+ {
+ if (file_exists(filename))
+ return true;
+ }
+ else
+ {
+ if (dir_exists(filename))
+ return true;
+ }
+ return false;
+}
+
+static const char* _get_user_file_path(const char *path,
+ unsigned flags,
+ char* buf,
+ const size_t bufsize)
{
const char *ret = path;
const char *pos = path;
- printf("%s(): looking for %s\n", __func__, path);
/* replace ROCKBOX_DIR in path with $HOME/.config/rockbox.org */
pos += ROCKBOX_DIR_LEN;
if (*pos == '/') pos += 1;
@@ -66,27 +114,99 @@ const char* get_user_file_path(const char *path,
* write access is needed */
if (flags & NEED_WRITE)
ret = buf;
- else
+ else if (try_path(buf, flags))
+ ret = buf;
+
+ if (ret != buf) /* not found in $HOME, try ROCKBOX_BASE_DIR, !NEED_WRITE only */
{
- if (flags & IS_FILE)
- {
- if (file_exists(buf))
- ret = buf;
- }
- else
- {
- if (dir_exists(buf))
- ret = buf;
- }
+ if (snprintf(buf, bufsize, ROCKBOX_SHARE_PATH "/%s", pos) >= (int)bufsize)
+ return NULL;
+
+ if (try_path(buf, flags))
+ ret = buf;
}
- /* make a copy if we're about to return the path*/
- if (UNLIKELY((flags & FORCE_BUFFER_COPY) && (ret != buf)))
+ return ret;
+}
+
+int app_open(const char *name, int o, ...)
+{
+ char realpath[MAX_PATH];
+ va_list ap;
+ int fd;
+
+ if (!strncmp(ROCKBOX_DIR, name, ROCKBOX_DIR_LEN))
{
- strlcpy(buf, ret, bufsize);
- ret = buf;
+ int flags = IS_FILE;
+ if (o & (O_CREAT|O_RDWR|O_TRUNC|O_WRONLY))
+ flags |= NEED_WRITE;
+ name = _get_user_file_path(name, flags, realpath, sizeof(realpath));
}
+ va_start(ap, o);
+ fd = open(name, o, ap);
+ va_end(ap);
+
+ return fd;
+
+}
- printf("%s(): %s\n", __func__, ret);
- return ret;
+int app_creat(const char* name, mode_t mode)
+{
+ return app_open(name, O_CREAT|O_WRONLY|O_TRUNC, mode);
}
+
+int app_remove(const char *name)
+{
+ char realpath[MAX_PATH];
+ const char *fname = name;
+ if (!strncmp(ROCKBOX_DIR, name, ROCKBOX_DIR_LEN))
+ {
+ fname = _get_user_file_path(name, 0, realpath, sizeof(realpath));
+ }
+ return remove(fname);
+}
+
+int app_rename(const char *old, const char *new)
+{
+ char realpath[MAX_PATH];
+ const char *fname = old;
+ if (!strncmp(ROCKBOX_DIR, old, ROCKBOX_DIR_LEN))
+ {
+ fname = _get_user_file_path(old, 0, realpath, sizeof(realpath));
+ }
+ return rename(fname, new);
+}
+
+DIR *app_opendir(const char *name)
+{
+ char realpath[MAX_PATH];
+ const char *fname = name;
+ if (!strncmp(ROCKBOX_DIR, name, ROCKBOX_DIR_LEN))
+ {
+ fname = _get_user_file_path(name, 0, realpath, sizeof(realpath));
+ }
+ return opendir(fname);
+}
+
+int app_mkdir(const char* name)
+{
+ char realpath[MAX_PATH];
+ const char *fname = name;
+ if (!strncmp(ROCKBOX_DIR, name, ROCKBOX_DIR_LEN))
+ {
+ fname = _get_user_file_path(name, 0, realpath, sizeof(realpath));
+ }
+ return mkdir(fname);
+}
+
+int app_rmdir(const char* name)
+{
+ char realpath[MAX_PATH];
+ const char *fname = name;
+ if (!strncmp(ROCKBOX_DIR, name, ROCKBOX_DIR_LEN))
+ {
+ fname = _get_user_file_path(name, 0, realpath, sizeof(realpath));
+ }
+ return rmdir(fname);
+}
+
diff --git a/firmware/export/rbpaths.h b/firmware/export/rbpaths.h
index cd87888cef..6c5d769ed8 100644
--- a/firmware/export/rbpaths.h
+++ b/firmware/export/rbpaths.h
@@ -26,17 +26,6 @@
#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 */
@@ -67,35 +56,17 @@
#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 PLUGIN_DIR ROCKBOX_LIBRARY_PATH "/rocks"
+#define CODECS_DIR ROCKBOX_LIBRARY_PATH "/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"
diff --git a/firmware/font.c b/firmware/font.c
index e973108bca..cd74459b1e 100644
--- a/firmware/font.c
+++ b/firmware/font.c
@@ -613,11 +613,7 @@ void glyph_cache_save(struct font* pf)
pf = &font_ui;
if (pf->fd >= 0 && pf == &font_ui)
{
- 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);
+ cache_fd = open(GLYPH_CACHE_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0666);
if (cache_fd < 0)
return;
@@ -678,7 +674,6 @@ static void glyph_cache_load(struct font* pf)
int i, size;
unsigned char tmp[2];
unsigned short ch;
- char path[MAX_PATH];
unsigned short glyphs[MAX_SORT];
unsigned short glyphs_lru_order[MAX_SORT];
int glyph_file_skip=0, glyph_file_size=0;
@@ -687,8 +682,7 @@ static void glyph_cache_load(struct font* pf)
if ( sort_size > MAX_SORT )
sort_size = MAX_SORT;
- fd = open(get_user_file_path(GLYPH_CACHE_FILE, IS_FILE|NEED_WRITE,
- path, sizeof(path)), O_RDONLY|O_BINARY);
+ fd = open(GLYPH_CACHE_FILE, O_RDONLY|O_BINARY);
if (fd >= 0) {
/* only read what fits */
diff --git a/firmware/include/dir.h b/firmware/include/dir.h
index 29dcb65961..3a582c3865 100644
--- a/firmware/include/dir.h
+++ b/firmware/include/dir.h
@@ -49,7 +49,6 @@
#define ATTR_ARCHIVE 0x20
#define ATTR_VOLUME 0x40 /* this is a volume, not a real directory */
-#if (CONFIG_PLATFORM & (PLATFORM_NATIVE|PLATFORM_SDL))
#ifdef HAVE_DIRCACHE
# include "dircache.h"
# define DIR DIR_CACHED
@@ -61,7 +60,7 @@
# define mkdir mkdir_cached
# define rmdir rmdir_cached
#else
-#include "dir_uncached.h"
+# include "dir_uncached.h"
# define DIR DIR_UNCACHED
# define dirent dirent_uncached
# define opendir opendir_uncached
@@ -71,9 +70,5 @@
# define mkdir mkdir_uncached
# define rmdir rmdir_uncached
#endif
-#else
-#include "dir-target.h"
-#include "dir_uncached.h"
-#endif
#endif
diff --git a/firmware/include/dir_uncached.h b/firmware/include/dir_uncached.h
index 29512c7a69..3bae07177b 100644
--- a/firmware/include/dir_uncached.h
+++ b/firmware/include/dir_uncached.h
@@ -34,13 +34,13 @@ struct dirinfo {
#include "file.h"
#if (CONFIG_PLATFORM & PLATFORM_SDL)
-#define dirent_uncached sim_dirent
-#define DIR_UNCACHED SIM_DIR
-#define opendir_uncached sim_opendir
-#define readdir_uncached sim_readdir
-#define closedir_uncached sim_closedir
-#define mkdir_uncached sim_mkdir
-#define rmdir_uncached sim_rmdir
+# define dirent_uncached sim_dirent
+# define DIR_UNCACHED SIM_DIR
+# define opendir_uncached sim_opendir
+# define readdir_uncached sim_readdir
+# define closedir_uncached sim_closedir
+# define mkdir_uncached sim_mkdir
+# define rmdir_uncached sim_rmdir
#endif
#ifndef DIRENT_DEFINED
@@ -54,6 +54,7 @@ struct dirent_uncached {
#include "fat.h"
+#ifndef DIR_DEFINED
typedef struct {
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
bool busy;
@@ -69,6 +70,24 @@ typedef struct {
char *name;
#endif
} DIR_UNCACHED;
+#endif
+
+
+#if defined(APPLICATION)
+#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
+#include "dir-target.h"
+#endif
+# undef opendir_uncached
+# define opendir_uncached app_opendir
+# undef mkdir_uncached
+# define mkdir_uncached app_mkdir
+# undef rmdir_uncached
+# define rmdir_uncached app_rmdir
+/* defined in rbpaths.c */
+extern DIR_UNCACHED* app_opendir(const char* name);
+extern int app_rmdir(const char* name);
+extern int app_mkdir(const char* name);
+#endif
#ifdef HAVE_HOTSWAP
char *get_volume_name(int volume);
diff --git a/firmware/include/file.h b/firmware/include/file.h
index 8711124391..ee52c3f2b7 100644
--- a/firmware/include/file.h
+++ b/firmware/include/file.h
@@ -37,20 +37,38 @@
#define MAX_OPEN_FILES 11
#if !defined(PLUGIN) && !defined(CODEC)
-#if (CONFIG_PLATFORM & PLATFORM_SDL)
-#define open(x, ...) sim_open(x, __VA_ARGS__)
-#define creat(x,m) sim_creat(x,m)
-#define remove(x) sim_remove(x)
-#define rename(x,y) sim_rename(x,y)
-#define filesize(x) sim_filesize(x)
-#define fsync(x) sim_fsync(x)
-#define ftruncate(x,y) sim_ftruncate(x,y)
-#define lseek(x,y,z) sim_lseek(x,y,z)
-#define read(x,y,z) sim_read(x,y,z)
-#define write(x,y,z) sim_write(x,y,z)
-#define close(x) sim_close(x)
-extern int sim_creat(const char *pathname, mode_t mode);
-extern int sim_open(const char *pathname, int flags, ...);
+#if defined(APPLICATION)
+# define open(x, ...) app_open(x, __VA_ARGS__)
+# define creat(x,m) app_creat(x, m)
+# define remove(x) app_remove(x)
+# define rename(x,y) app_rename(x,y)
+extern int app_open(const char *name, int o, ...);
+extern int app_creat(const char *name, mode_t mode);
+extern int app_remove(const char* pathname);
+extern int app_rename(const char* path, const char* newname);
+# if (CONFIG_PLATFORM & PLATFORM_SDL)
+# define filesize(x) sim_filesize(x)
+# define fsync(x) sim_fsync(x)
+# define ftruncate(x,y) sim_ftruncate(x,y)
+# define lseek(x,y,z) sim_lseek(x,y,z)
+# define read(x,y,z) sim_read(x,y,z)
+# define write(x,y,z) sim_write(x,y,z)
+# define close(x) sim_close(x)
+# endif
+#elif defined(SIMULATOR)
+# define open(x, ...) sim_open(x, __VA_ARGS__)
+# define creat(x,m) sim_creat(x,m)
+# define remove(x) sim_remove(x)
+# define rename(x,y) sim_rename(x,y)
+# define filesize(x) sim_filesize(x)
+# define fsync(x) sim_fsync(x)
+# define ftruncate(x,y) sim_ftruncate(x,y)
+# define lseek(x,y,z) sim_lseek(x,y,z)
+# define read(x,y,z) sim_read(x,y,z)
+# define write(x,y,z) sim_write(x,y,z)
+# define close(x) sim_close(x)
+extern int sim_open(const char *name, int o, ...);
+extern int sim_creat(const char *name, mode_t mode);
#endif
typedef int (*open_func)(const char* pathname, int flags, ...);
diff --git a/firmware/load_code.c b/firmware/load_code.c
index 5b5307e622..2337ee5cad 100644
--- a/firmware/load_code.c
+++ b/firmware/load_code.c
@@ -144,17 +144,15 @@ void *lc_open_from_mem(void *addr, size_t blob_size)
for (i = 0; i < 10; i++)
{
#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
- /* we need that path fixed, since get_user_file_path()
+ /* we need that path fixed, since _get_user_file_path()
* gives us the folder on the sdcard where we cannot load libraries
* from (no exec permissions)
*/
snprintf(temp_filename, sizeof(temp_filename),
"/data/data/org.rockbox/app_rockbox/libtemp_binary_%d.so", i);
#else
- char name[MAX_PATH];
- const char *_name = get_user_file_path(ROCKBOX_DIR, NEED_WRITE, name, sizeof(name));
snprintf(temp_filename, sizeof(temp_filename),
- "%s/libtemp_binary_%d.dll", _name, i);
+ ROCKBOX_DIR "/libtemp_binary_%d.dll", i);
#endif
fd = open(temp_filename, O_WRONLY|O_CREAT|O_TRUNC, 0700);
if (fd >= 0)
diff --git a/firmware/target/hosted/android/dir-target.h b/firmware/target/hosted/android/dir-target.h
index c93d92caad..c6c6b4b2b0 100644
--- a/firmware/target/hosted/android/dir-target.h
+++ b/firmware/target/hosted/android/dir-target.h
@@ -24,10 +24,21 @@
#include <dirent.h>
-#define opendir _opendir
-#define mkdir _mkdir
-#define closedir _closedir
-#define readdir _readdir
+#define dirent_uncached dirent
+#define DIR_UNCACHED DIR
+#define opendir_uncached _opendir
+#define readdir_uncached _readdir
+#define closedir_uncached _closedir
+#define mkdir_uncached _mkdir
+#define rmdir_uncached rmdir
+
+#define dirent_android dirent
+#define DIR_android DIR
+#define opendir_android _opendir
+#define readdir_android _readdir
+#define closedir_android _closedir
+#define mkdir_android _mkdir
+#define rmdir_android rmdir
extern DIR* _opendir(const char* name);
extern int _mkdir(const char* name);
@@ -36,5 +47,7 @@ extern struct dirent *_readdir(DIR* dir);
extern void fat_size(unsigned long *size, unsigned long *free);
#define DIRFUNCTIONS_DEFINED
+#define DIRENT_DEFINED
+#define DIR_DEFINED
#endif /* __DIR_TARGET_H__ */
diff --git a/firmware/target/hosted/android/fs-android.c b/firmware/target/hosted/android/fs-android.c
index 5209458e54..1967198d3d 100644
--- a/firmware/target/hosted/android/fs-android.c
+++ b/firmware/target/hosted/android/fs-android.c
@@ -29,6 +29,7 @@
#include "dir-target.h"
#include "file.h"
#include "dir.h"
+#include "rbpaths.h"
long filesize(int fd)
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index 3591905e32..fe7bad438f 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -293,7 +293,6 @@ static const char *get_sim_pathname(const char *name)
MYDIR *sim_opendir(const char *name)
{
DIR_T *dir;
-
dir = (DIR_T *) OPENDIR(get_sim_pathname(name));
if (dir)