forked from len0rd/rockbox
Get rid of get_user_file_path and do the path handling in wrappers for open() and friends.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28752 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c35b43b0f5
commit
2c2416094f
25 changed files with 311 additions and 288 deletions
|
@ -219,15 +219,14 @@ static void read_config(const char* config_file);
|
||||||
* load a colors file from a theme with:
|
* load a colors file from a theme with:
|
||||||
* filetype colours: filename.colours */
|
* filetype colours: filename.colours */
|
||||||
void read_color_theme_file(void) {
|
void read_color_theme_file(void) {
|
||||||
char buffer[MAX_PATH], dir[MAX_PATH];
|
char buffer[MAX_PATH];
|
||||||
int fd;
|
int fd;
|
||||||
char *ext, *color;
|
char *ext, *color;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < MAX_FILETYPES+1; i++) {
|
for (i = 0; i < MAX_FILETYPES+1; i++) {
|
||||||
custom_colors[i] = -1;
|
custom_colors[i] = -1;
|
||||||
}
|
}
|
||||||
snprintf(buffer, MAX_PATH, "%s/%s.colours",
|
snprintf(buffer, MAX_PATH, THEME_DIR "/%s.colours",
|
||||||
get_user_file_path(THEME_DIR, 0, dir, sizeof(dir)),
|
|
||||||
global_settings.colors_file);
|
global_settings.colors_file);
|
||||||
fd = open(buffer, O_RDONLY);
|
fd = open(buffer, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
|
@ -300,7 +299,6 @@ void read_viewer_theme_file(void)
|
||||||
|
|
||||||
void filetype_init(void)
|
void filetype_init(void)
|
||||||
{
|
{
|
||||||
char path[MAX_PATH];
|
|
||||||
/* set the directory item first */
|
/* set the directory item first */
|
||||||
filetypes[0].extension = NULL;
|
filetypes[0].extension = NULL;
|
||||||
filetypes[0].plugin = NULL;
|
filetypes[0].plugin = NULL;
|
||||||
|
@ -310,7 +308,7 @@ void filetype_init(void)
|
||||||
viewer_count = 0;
|
viewer_count = 0;
|
||||||
filetype_count = 1;
|
filetype_count = 1;
|
||||||
read_builtin_types();
|
read_builtin_types();
|
||||||
read_config(get_user_file_path(VIEWERS_CONFIG, IS_FILE, path, sizeof(path)));
|
read_config(VIEWERS_CONFIG);
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
read_viewer_theme_file();
|
read_viewer_theme_file();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -228,12 +228,9 @@ static void load_icons(const char* filename, enum Iconset iconset)
|
||||||
if (filename[0] && filename[0] != '-')
|
if (filename[0] && filename[0] != '-')
|
||||||
{
|
{
|
||||||
char path[MAX_PATH];
|
char path[MAX_PATH];
|
||||||
char temp[MAX_PATH];
|
|
||||||
const char * fname;
|
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "%s/%s.bmp", ICON_DIR, filename);
|
snprintf(path, sizeof(path), ICON_DIR "/%s.bmp", filename);
|
||||||
fname = get_user_file_path(path, IS_FILE, temp, sizeof(temp));
|
size_read = read_bmp_file(path, bmp, IMG_BUFSIZE, bmpformat, NULL);
|
||||||
size_read = read_bmp_file(fname, bmp, IMG_BUFSIZE, bmpformat, NULL);
|
|
||||||
if (size_read > 0)
|
if (size_read > 0)
|
||||||
{
|
{
|
||||||
*loaded_ok = true;
|
*loaded_ok = true;
|
||||||
|
|
|
@ -54,7 +54,6 @@ void skin_backdrop_init(void)
|
||||||
int skin_backdrop_assign(char* backdrop, char *bmpdir,
|
int skin_backdrop_assign(char* backdrop, char *bmpdir,
|
||||||
enum screen_type screen)
|
enum screen_type screen)
|
||||||
{
|
{
|
||||||
char dir[MAX_PATH];
|
|
||||||
char filename[MAX_PATH];
|
char filename[MAX_PATH];
|
||||||
int i, free = -1;
|
int i, free = -1;
|
||||||
if (!backdrop)
|
if (!backdrop)
|
||||||
|
@ -68,8 +67,7 @@ int skin_backdrop_assign(char* backdrop, char *bmpdir,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char *bd_dir = get_user_file_path(bmpdir, 0, dir, sizeof(dir));
|
get_image_filename(backdrop, bmpdir, filename, sizeof(filename));
|
||||||
get_image_filename(backdrop, bd_dir, filename, sizeof(filename));
|
|
||||||
}
|
}
|
||||||
for (i=0; i<NB_BDROPS; i++)
|
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] &&
|
if (screen == SCREEN_MAIN && global_settings.backdrop_file[0] &&
|
||||||
global_settings.backdrop_file[0] != '-' && filename[0] == '-')
|
global_settings.backdrop_file[0] != '-' && filename[0] == '-')
|
||||||
{
|
{
|
||||||
char dir[MAX_PATH];
|
|
||||||
char* temp = filename+2; /* slightly hacky to get a buffer */
|
char* temp = filename+2; /* slightly hacky to get a buffer */
|
||||||
size_t size = sizeof(backdrops[i].name) - 2;
|
size_t size = sizeof(backdrops[i].name) - 2;
|
||||||
snprintf(temp, size, "%s/%s.bmp",
|
snprintf(temp, size, BACKDROP_DIR "/%s.bmp", global_settings.backdrop_file);
|
||||||
get_user_file_path(BACKDROP_DIR, 0, dir, sizeof(dir)),
|
|
||||||
global_settings.backdrop_file);
|
|
||||||
filename = temp;
|
filename = temp;
|
||||||
}
|
}
|
||||||
if (*filename && *filename != '-')
|
if (*filename && *filename != '-')
|
||||||
|
@ -161,7 +156,7 @@ void skin_backdrop_unload(int backdrop_id)
|
||||||
void skin_backdrop_load_setting(void)
|
void skin_backdrop_load_setting(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char filename[MAX_PATH], dir[MAX_PATH];
|
char filename[MAX_PATH];
|
||||||
for(i=0;i<SKINNABLE_SCREENS_COUNT*NB_SCREENS;i++)
|
for(i=0;i<SKINNABLE_SCREENS_COUNT*NB_SCREENS;i++)
|
||||||
{
|
{
|
||||||
if (backdrops[i].name[0] == '-' && backdrops[i].screen == SCREEN_MAIN)
|
if (backdrops[i].name[0] == '-' && backdrops[i].screen == SCREEN_MAIN)
|
||||||
|
@ -171,8 +166,7 @@ void skin_backdrop_load_setting(void)
|
||||||
{
|
{
|
||||||
if (!backdrops[i].buffer)
|
if (!backdrops[i].buffer)
|
||||||
backdrops[i].buffer = (char*)skin_buffer_alloc(LCD_BACKDROP_BYTES);
|
backdrops[i].buffer = (char*)skin_buffer_alloc(LCD_BACKDROP_BYTES);
|
||||||
snprintf(filename, sizeof filename, "%s/%s.bmp",
|
snprintf(filename, sizeof filename, BACKDROP_DIR "/%s.bmp",
|
||||||
get_user_file_path(BACKDROP_DIR, 0, dir, sizeof(dir)),
|
|
||||||
global_settings.backdrop_file);
|
global_settings.backdrop_file);
|
||||||
bool loaded = backdrops[i].buffer &&
|
bool loaded = backdrops[i].buffer &&
|
||||||
screens[SCREEN_MAIN].backdrop_load(filename,
|
screens[SCREEN_MAIN].backdrop_load(filename,
|
||||||
|
|
|
@ -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)
|
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;
|
char *setting = NULL, *ext = NULL;
|
||||||
switch (skin)
|
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 */
|
buf[0] = '\0'; /* force it to reload the default */
|
||||||
if (strcmp(setting, "rockbox_failsafe"))
|
if (strcmp(setting, "rockbox_failsafe"))
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof buf, "%s/%s.%s",
|
snprintf(buf, sizeof buf, WPS_DIR "/%s.%s", setting, ext);
|
||||||
get_user_file_path(WPS_DIR, false, path, sizeof(path)),
|
|
||||||
setting, ext);
|
|
||||||
}
|
}
|
||||||
cpu_boost(true);
|
cpu_boost(true);
|
||||||
skin_load(skin, screen, buf, true);
|
skin_load(skin, screen, buf, true);
|
||||||
|
|
|
@ -64,7 +64,6 @@ int skin_font_load(char* font_name, int glyphs)
|
||||||
struct font *pf;
|
struct font *pf;
|
||||||
struct skin_font_info *font = NULL;
|
struct skin_font_info *font = NULL;
|
||||||
char filename[MAX_PATH];
|
char filename[MAX_PATH];
|
||||||
char tmp[MAX_PATH];
|
|
||||||
|
|
||||||
if (!strcmp(font_name, global_settings.font_file))
|
if (!strcmp(font_name, global_settings.font_file))
|
||||||
return FONT_UI;
|
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))
|
if (!strcmp(font_name, global_settings.remote_font_file))
|
||||||
return FONT_UI_REMOTE;
|
return FONT_UI_REMOTE;
|
||||||
#endif
|
#endif
|
||||||
snprintf(tmp, MAX_PATH, FONT_DIR "/%s.fnt", font_name);
|
snprintf(filename, MAX_PATH, FONT_DIR "/%s.fnt", font_name);
|
||||||
get_user_file_path(tmp, FORCE_BUFFER_COPY, filename, sizeof(filename));
|
|
||||||
|
|
||||||
for(i=0;i<MAXUSERFONTS;i++)
|
for(i=0;i<MAXUSERFONTS;i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1646,8 +1646,7 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
|
||||||
strlcpy(bmpdir, buf, dot - buf + 1);
|
strlcpy(bmpdir, buf, dot - buf + 1);
|
||||||
}
|
}
|
||||||
else
|
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);
|
snprintf(bmpdir, MAX_PATH, "%s", BACKDROP_DIR);
|
||||||
}
|
}
|
||||||
/* load the bitmaps that were found by the parsing */
|
/* load the bitmaps that were found by the parsing */
|
||||||
|
|
|
@ -172,13 +172,13 @@ int main(void)
|
||||||
#ifdef AUTOROCK
|
#ifdef AUTOROCK
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH];
|
char filename[MAX_PATH];
|
||||||
const char *file = get_user_file_path(
|
const char *file =
|
||||||
#ifdef APPLICATION
|
#ifdef APPLICATION
|
||||||
ROCKBOX_DIR
|
ROCKBOX_DIR
|
||||||
#else
|
#else
|
||||||
PLUGIN_APPS_DIR
|
PLUGIN_APPS_DIR
|
||||||
#endif
|
#endif
|
||||||
"/autostart.rock", NEED_WRITE|IS_FILE, filename, sizeof(filename));
|
"/autostart.rock";
|
||||||
if(file_exists(file)) /* no complaint if it doesn't exist */
|
if(file_exists(file)) /* no complaint if it doesn't exist */
|
||||||
{
|
{
|
||||||
plugin_load(file, NULL); /* start if it does */
|
plugin_load(file, NULL); /* start if it does */
|
||||||
|
|
|
@ -246,11 +246,9 @@ static struct browse_folder_info themes = {THEME_DIR, SHOW_CFG};
|
||||||
|
|
||||||
int browse_folder(void *param)
|
int browse_folder(void *param)
|
||||||
{
|
{
|
||||||
char path[MAX_PATH];
|
|
||||||
const struct browse_folder_info *info =
|
const struct browse_folder_info *info =
|
||||||
(const struct browse_folder_info*)param;
|
(const struct browse_folder_info*)param;
|
||||||
return rockbox_browse(get_user_file_path(info->dir, 0, path, sizeof(path)),
|
return rockbox_browse(info->dir, info->show_options);
|
||||||
info->show_options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
|
|
@ -1439,12 +1439,7 @@ static int get_next_dir(char *dir, bool is_forward, bool recursion)
|
||||||
/* process random folder advance */
|
/* process random folder advance */
|
||||||
if (global_settings.next_folder == FOLDER_ADVANCE_RANDOM)
|
if (global_settings.next_folder == FOLDER_ADVANCE_RANDOM)
|
||||||
{
|
{
|
||||||
char folder_advance_list[MAX_PATH];
|
int fd = open(ROCKBOX_DIR "/folder_advance_list.dat", O_RDONLY);
|
||||||
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);
|
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
{
|
{
|
||||||
char buffer[MAX_PATH];
|
char buffer[MAX_PATH];
|
||||||
|
@ -1914,8 +1909,7 @@ void playlist_init(void)
|
||||||
struct playlist_info* playlist = ¤t_playlist;
|
struct playlist_info* playlist = ¤t_playlist;
|
||||||
|
|
||||||
playlist->current = true;
|
playlist->current = true;
|
||||||
get_user_file_path(PLAYLIST_CONTROL_FILE, IS_FILE|NEED_WRITE|FORCE_BUFFER_COPY,
|
strlcpy(playlist->control_filename, PLAYLIST_CONTROL_FILE,
|
||||||
playlist->control_filename,
|
|
||||||
sizeof(playlist->control_filename));
|
sizeof(playlist->control_filename));
|
||||||
playlist->fd = -1;
|
playlist->fd = -1;
|
||||||
playlist->control_fd = -1;
|
playlist->control_fd = -1;
|
||||||
|
|
|
@ -81,11 +81,9 @@ static int initialize_catalog(void)
|
||||||
/* fall back to default directory if no or invalid config */
|
/* fall back to default directory if no or invalid config */
|
||||||
if (default_dir)
|
if (default_dir)
|
||||||
{
|
{
|
||||||
const char *dir = get_user_file_path(PLAYLIST_CATALOG_DEFAULT_DIR,
|
strcpy(playlist_dir, PLAYLIST_CATALOG_DEFAULT_DIR);
|
||||||
FORCE_BUFFER_COPY|NEED_WRITE,
|
if (!dir_exists(playlist_dir))
|
||||||
playlist_dir, sizeof(playlist_dir));
|
mkdir(playlist_dir);
|
||||||
if (!dir_exists(dir))
|
|
||||||
mkdir(dir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
playlist_dir_length = strlen(playlist_dir);
|
playlist_dir_length = strlen(playlist_dir);
|
||||||
|
|
|
@ -314,11 +314,11 @@ static const struct plugin_api rockbox_api = {
|
||||||
#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
|
#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
|
||||||
(creat_func)creat_wrapper,
|
(creat_func)creat_wrapper,
|
||||||
#else
|
#else
|
||||||
(creat_func)PREFIX(creat),
|
(creat_func)creat,
|
||||||
#endif
|
#endif
|
||||||
(write_func)PREFIX(write),
|
(write_func)PREFIX(write),
|
||||||
PREFIX(remove),
|
remove,
|
||||||
PREFIX(rename),
|
rename,
|
||||||
PREFIX(ftruncate),
|
PREFIX(ftruncate),
|
||||||
PREFIX(filesize),
|
PREFIX(filesize),
|
||||||
fdprintf,
|
fdprintf,
|
||||||
|
|
|
@ -118,9 +118,7 @@ static bool read_nvram_data(char* buf, int max_len)
|
||||||
unsigned crc32 = 0xffffffff;
|
unsigned crc32 = 0xffffffff;
|
||||||
int var_count = 0, i = 0, buf_pos = 0;
|
int var_count = 0, i = 0, buf_pos = 0;
|
||||||
#ifndef HAVE_RTC_RAM
|
#ifndef HAVE_RTC_RAM
|
||||||
char path[MAX_PATH];
|
int fd = open(NVRAM_FILE, O_RDONLY);
|
||||||
int fd = open(get_user_file_path(NVRAM_FILE, IS_FILE|NEED_WRITE,
|
|
||||||
path, sizeof(path)), O_RDONLY);
|
|
||||||
int bytes;
|
int bytes;
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return false;
|
return false;
|
||||||
|
@ -174,7 +172,6 @@ static bool write_nvram_data(char* buf, int max_len)
|
||||||
char var_count = 0;
|
char var_count = 0;
|
||||||
#ifndef HAVE_RTC_RAM
|
#ifndef HAVE_RTC_RAM
|
||||||
int fd;
|
int fd;
|
||||||
char path[MAX_PATH];
|
|
||||||
#endif
|
#endif
|
||||||
memset(buf,0,max_len);
|
memset(buf,0,max_len);
|
||||||
/* magic, version */
|
/* magic, version */
|
||||||
|
@ -198,8 +195,7 @@ static bool write_nvram_data(char* buf, int max_len)
|
||||||
max_len-NVRAM_DATA_START-1,0xffffffff);
|
max_len-NVRAM_DATA_START-1,0xffffffff);
|
||||||
memcpy(&buf[4],&crc32,4);
|
memcpy(&buf[4],&crc32,4);
|
||||||
#ifndef HAVE_RTC_RAM
|
#ifndef HAVE_RTC_RAM
|
||||||
fd = open(get_user_file_path(NVRAM_FILE, IS_FILE|NEED_WRITE,
|
fd = open(NVRAM_FILE,O_CREAT|O_TRUNC|O_WRONLY, 0666);
|
||||||
path, sizeof(path)),O_CREAT|O_TRUNC|O_WRONLY, 0666);
|
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
{
|
{
|
||||||
int len = write(fd,buf,max_len);
|
int len = write(fd,buf,max_len);
|
||||||
|
@ -230,12 +226,8 @@ void settings_load(int which)
|
||||||
read_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
|
read_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
|
||||||
if (which&SETTINGS_HD)
|
if (which&SETTINGS_HD)
|
||||||
{
|
{
|
||||||
const char *file;
|
settings_load_config(CONFIGFILE, false);
|
||||||
char path[MAX_PATH];
|
settings_load_config(FIXEDSETTINGSFILE, false);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,11 +588,8 @@ static void flush_global_status_callback(void *data)
|
||||||
static void flush_config_block_callback(void *data)
|
static void flush_config_block_callback(void *data)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
char path[MAX_PATH];
|
|
||||||
write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
|
write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
|
||||||
settings_write_config(
|
settings_write_config(CONFIGFILE, SETTINGS_SAVE_CHANGED);
|
||||||
get_user_file_path(CONFIGFILE, IS_FILE|NEED_WRITE, path, sizeof(path)),
|
|
||||||
SETTINGS_SAVE_CHANGED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -644,7 +633,7 @@ int settings_save(void)
|
||||||
|
|
||||||
bool settings_save_config(int options)
|
bool settings_save_config(int options)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH], path[MAX_PATH];
|
char filename[MAX_PATH];
|
||||||
const char *folder, *namebase;
|
const char *folder, *namebase;
|
||||||
switch (options)
|
switch (options)
|
||||||
{
|
{
|
||||||
|
@ -673,8 +662,6 @@ bool settings_save_config(int options)
|
||||||
namebase = "config";
|
namebase = "config";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
folder = get_user_file_path(folder, NEED_WRITE, path, sizeof(path));
|
|
||||||
create_numbered_filename(filename, folder, namebase, ".cfg", 2
|
create_numbered_filename(filename, folder, namebase, ".cfg", 2
|
||||||
IF_CNFN_NUM_(, NULL));
|
IF_CNFN_NUM_(, NULL));
|
||||||
|
|
||||||
|
@ -884,13 +871,11 @@ void settings_apply(bool read_disk)
|
||||||
{
|
{
|
||||||
char buf[MAX_PATH];
|
char buf[MAX_PATH];
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#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 */
|
/* fonts need to be loaded before the WPS */
|
||||||
if (global_settings.font_file[0]
|
if (global_settings.font_file[0]
|
||||||
&& 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);
|
global_settings.font_file);
|
||||||
CHART2(">font_load ", global_settings.font_file);
|
CHART2(">font_load ", global_settings.font_file);
|
||||||
rc = font_load(NULL, buf);
|
rc = font_load(NULL, buf);
|
||||||
|
@ -903,7 +888,7 @@ void settings_apply(bool read_disk)
|
||||||
#ifdef HAVE_REMOTE_LCD
|
#ifdef HAVE_REMOTE_LCD
|
||||||
if ( global_settings.remote_font_file[0]
|
if ( global_settings.remote_font_file[0]
|
||||||
&& 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);
|
global_settings.remote_font_file);
|
||||||
CHART2(">font_load_remoteui ", global_settings.remote_font_file);
|
CHART2(">font_load_remoteui ", global_settings.remote_font_file);
|
||||||
rc = font_load_remoteui(buf);
|
rc = font_load_remoteui(buf);
|
||||||
|
@ -915,8 +900,7 @@ void settings_apply(bool read_disk)
|
||||||
font_load_remoteui(NULL);
|
font_load_remoteui(NULL);
|
||||||
#endif
|
#endif
|
||||||
if ( global_settings.kbd_file[0]) {
|
if ( global_settings.kbd_file[0]) {
|
||||||
snprintf(buf, sizeof buf, "%s/%s.kbd",
|
snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd",
|
||||||
get_user_file_path(ROCKBOX_DIR, 0, dir, sizeof(dir)),
|
|
||||||
global_settings.kbd_file);
|
global_settings.kbd_file);
|
||||||
CHART(">load_kbd");
|
CHART(">load_kbd");
|
||||||
load_kbd(buf);
|
load_kbd(buf);
|
||||||
|
@ -925,8 +909,6 @@ void settings_apply(bool read_disk)
|
||||||
else
|
else
|
||||||
load_kbd(NULL);
|
load_kbd(NULL);
|
||||||
#endif /* HAVE_LCD_BITMAP */
|
#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]) {
|
if ( global_settings.lang_file[0]) {
|
||||||
snprintf(buf, sizeof buf, LANG_DIR "/%s.lng",
|
snprintf(buf, sizeof buf, LANG_DIR "/%s.lng",
|
||||||
global_settings.lang_file);
|
global_settings.lang_file);
|
||||||
|
|
135
apps/tagcache.c
135
apps/tagcache.c
|
@ -73,9 +73,9 @@
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "crc32.h"
|
#include "crc32.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "filefuncs.h"
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "dir.h"
|
#include "dir.h"
|
||||||
|
#include "filefuncs.h"
|
||||||
#include "structec.h"
|
#include "structec.h"
|
||||||
|
|
||||||
#ifndef __PCTOOL__
|
#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)
|
static int open_tag_fd(struct tagcache_header *hdr, int tag, bool write)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
char buf[MAX_PATH], path[MAX_PATH];
|
char buf[MAX_PATH];
|
||||||
const char * file;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (TAGCACHE_IS_NUMERIC(tag) || tag < 0 || tag >= TAG_COUNT)
|
if (TAGCACHE_IS_NUMERIC(tag) || tag < 0 || tag >= TAG_COUNT)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, tag);
|
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)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
logf("tag file open failed: tag=%d write=%d file=%s", tag, write, buf);
|
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 fd;
|
||||||
int rc;
|
int rc;
|
||||||
char path[MAX_PATH];
|
|
||||||
|
|
||||||
fd = open(get_user_file_path(TAGCACHE_FILE_MASTER,
|
fd = open(TAGCACHE_FILE_MASTER, write ? O_RDWR : O_RDONLY);
|
||||||
IS_FILE|NEED_WRITE,
|
|
||||||
path, sizeof(path)),
|
|
||||||
write ? O_RDWR : O_RDONLY);
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
logf("master file open failed for R/W");
|
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)
|
if (tcs->idxfd[tag] < 0)
|
||||||
{
|
{
|
||||||
char fn[MAX_PATH], path[MAX_PATH];
|
char fn[MAX_PATH];
|
||||||
const char *file;
|
|
||||||
|
|
||||||
snprintf(fn, sizeof fn, TAGCACHE_FILE_INDEX, tag);
|
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(fn, O_RDONLY);
|
||||||
tcs->idxfd[tag] = open(file, O_RDONLY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tcs->idxfd[tag] < 0)
|
if (tcs->idxfd[tag] < 0)
|
||||||
|
@ -1218,17 +1210,14 @@ static void remove_files(void)
|
||||||
tc_stat.ready = false;
|
tc_stat.ready = false;
|
||||||
tc_stat.ramcache = false;
|
tc_stat.ramcache = false;
|
||||||
tc_stat.econ = false;
|
tc_stat.econ = false;
|
||||||
remove(get_user_file_path(TAGCACHE_FILE_MASTER, NEED_WRITE|IS_FILE,
|
remove(TAGCACHE_FILE_MASTER);
|
||||||
buf, sizeof(buf)));
|
|
||||||
for (i = 0; i < TAG_COUNT; i++)
|
for (i = 0; i < TAG_COUNT; i++)
|
||||||
{
|
{
|
||||||
char buf2[MAX_PATH];
|
|
||||||
if (TAGCACHE_IS_NUMERIC(i))
|
if (TAGCACHE_IS_NUMERIC(i))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* database_%d.tcd -> database_0.tcd */
|
|
||||||
snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, i);
|
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)
|
if (!TAGCACHE_IS_NUMERIC(clause->tag) && tcs->idxfd[clause->tag] < 0)
|
||||||
{
|
{
|
||||||
char buf[MAX_PATH], path[MAX_PATH];
|
char buf[MAX_PATH];
|
||||||
const char *file;
|
|
||||||
snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, clause->tag);
|
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(buf, O_RDONLY);
|
||||||
tcs->idxfd[clause->tag] = open(file, O_RDONLY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tcs->clause[tcs->clause_count] = clause;
|
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 master_header tcmh;
|
||||||
struct index_entry idxbuf[IDX_BUF_DEPTH];
|
struct index_entry idxbuf[IDX_BUF_DEPTH];
|
||||||
int idxbuf_pos;
|
int idxbuf_pos;
|
||||||
char buf[TAG_MAXLEN+32], path[MAX_PATH];
|
char buf[TAG_MAXLEN+32];
|
||||||
const char *file;
|
|
||||||
int fd = -1, masterfd;
|
int fd = -1, masterfd;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
int init;
|
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.
|
* anything whether the index type is sorted or not.
|
||||||
*/
|
*/
|
||||||
snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, index_type);
|
snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, index_type);
|
||||||
file = get_user_file_path(buf, IS_FILE | NEED_WRITE, path, sizeof(path));
|
fd = open(buf, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||||
fd = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
logf("%s open fail", buf);
|
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". */
|
/* Loading the tag lookup file as "master file". */
|
||||||
logf("Loading index file");
|
logf("Loading index file");
|
||||||
masterfd = open(file, O_RDWR);
|
masterfd = open(TAGCACHE_FILE_MASTER, O_RDWR);
|
||||||
|
|
||||||
if (masterfd < 0)
|
if (masterfd < 0)
|
||||||
{
|
{
|
||||||
logf("Creating new DB");
|
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)
|
if (masterfd < 0)
|
||||||
{
|
{
|
||||||
logf("Failure to create index file (%s)", file);
|
logf("Failure to create index file (%s)", TAGCACHE_FILE_MASTER);
|
||||||
close(fd);
|
close(fd);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
@ -2899,8 +2882,6 @@ static bool commit(void)
|
||||||
{
|
{
|
||||||
struct tagcache_header tch;
|
struct tagcache_header tch;
|
||||||
struct master_header tcmh;
|
struct master_header tcmh;
|
||||||
char path[MAX_PATH];
|
|
||||||
const char *file;
|
|
||||||
int i, len, rc;
|
int i, len, rc;
|
||||||
int tmpfd;
|
int tmpfd;
|
||||||
int masterfd;
|
int masterfd;
|
||||||
|
@ -2914,10 +2895,7 @@ static bool commit(void)
|
||||||
while (write_lock)
|
while (write_lock)
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
file = get_user_file_path(TAGCACHE_FILE_TEMP,
|
tmpfd = open(TAGCACHE_FILE_TEMP, O_RDONLY);
|
||||||
IS_FILE|NEED_WRITE, path, sizeof(path));
|
|
||||||
|
|
||||||
tmpfd = open(file, O_RDONLY);
|
|
||||||
if (tmpfd < 0)
|
if (tmpfd < 0)
|
||||||
{
|
{
|
||||||
logf("nothing to commit");
|
logf("nothing to commit");
|
||||||
|
@ -2933,7 +2911,7 @@ static bool commit(void)
|
||||||
{
|
{
|
||||||
logf("incorrect tmpheader");
|
logf("incorrect tmpheader");
|
||||||
close(tmpfd);
|
close(tmpfd);
|
||||||
remove(file);
|
remove(TAGCACHE_FILE_TEMP);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2941,7 +2919,7 @@ static bool commit(void)
|
||||||
{
|
{
|
||||||
logf("nothing to commit");
|
logf("nothing to commit");
|
||||||
close(tmpfd);
|
close(tmpfd);
|
||||||
remove(file);
|
remove(TAGCACHE_FILE_TEMP);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2949,8 +2927,7 @@ static bool commit(void)
|
||||||
tc_stat.ready = check_all_headers();
|
tc_stat.ready = check_all_headers();
|
||||||
|
|
||||||
#ifdef HAVE_EEPROM_SETTINGS
|
#ifdef HAVE_EEPROM_SETTINGS
|
||||||
remove(get_user_file_path(TAGCACHE_STATEFILE, IS_FILE | NEED_WRITE,
|
remove(TAGCACHE_STATEFILE);
|
||||||
path, sizeof(path)));
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* At first be sure to unload the ramcache! */
|
/* At first be sure to unload the ramcache! */
|
||||||
|
@ -3040,7 +3017,7 @@ static bool commit(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
close(tmpfd);
|
close(tmpfd);
|
||||||
remove(file);
|
remove(TAGCACHE_FILE_TEMP);
|
||||||
|
|
||||||
tc_stat.commit_step = 0;
|
tc_stat.commit_step = 0;
|
||||||
|
|
||||||
|
@ -3458,8 +3435,7 @@ bool tagcache_import_changelog(void)
|
||||||
struct tagcache_header tch;
|
struct tagcache_header tch;
|
||||||
int clfd;
|
int clfd;
|
||||||
long masterfd;
|
long masterfd;
|
||||||
char buf[MAX(MAX_PATH, 2048)];
|
char buf[2048];
|
||||||
const char *file;
|
|
||||||
|
|
||||||
if (!tc_stat.ready)
|
if (!tc_stat.ready)
|
||||||
return false;
|
return false;
|
||||||
|
@ -3467,9 +3443,7 @@ bool tagcache_import_changelog(void)
|
||||||
while (read_lock)
|
while (read_lock)
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
file = get_user_file_path(TAGCACHE_FILE_CHANGELOG,
|
clfd = open(TAGCACHE_FILE_CHANGELOG, O_RDONLY);
|
||||||
IS_FILE|NEED_WRITE, buf, sizeof(buf));
|
|
||||||
clfd = open(file, O_RDONLY);
|
|
||||||
if (clfd < 0)
|
if (clfd < 0)
|
||||||
{
|
{
|
||||||
logf("failure to open changelog");
|
logf("failure to open changelog");
|
||||||
|
@ -3511,8 +3485,7 @@ bool tagcache_create_changelog(struct tagcache_search *tcs)
|
||||||
{
|
{
|
||||||
struct master_header myhdr;
|
struct master_header myhdr;
|
||||||
struct index_entry idx;
|
struct index_entry idx;
|
||||||
const char *file;
|
char buf[TAG_MAXLEN+32];
|
||||||
char buf[MAX(TAG_MAXLEN+32, MAX_PATH)];
|
|
||||||
char temp[32];
|
char temp[32];
|
||||||
int clfd;
|
int clfd;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -3524,9 +3497,7 @@ bool tagcache_create_changelog(struct tagcache_search *tcs)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Initialize the changelog */
|
/* Initialize the changelog */
|
||||||
file = get_user_file_path(TAGCACHE_FILE_CHANGELOG, IS_FILE | NEED_WRITE,
|
clfd = open(TAGCACHE_FILE_CHANGELOG, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||||
buf, sizeof(buf));
|
|
||||||
clfd = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
|
||||||
if (clfd < 0)
|
if (clfd < 0)
|
||||||
{
|
{
|
||||||
logf("failure to open changelog");
|
logf("failure to open changelog");
|
||||||
|
@ -3844,15 +3815,11 @@ static bool allocate_tagcache(void)
|
||||||
static bool tagcache_dumpload(void)
|
static bool tagcache_dumpload(void)
|
||||||
{
|
{
|
||||||
struct statefile_header shdr;
|
struct statefile_header shdr;
|
||||||
char path[MAX_PATH];
|
|
||||||
const char *file;
|
|
||||||
int fd, rc;
|
int fd, rc;
|
||||||
long offpos;
|
long offpos;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
file = get_user_file_path(TAGCACHE_STATEFILE, IS_FILE | NEED_WRITE,
|
fd = open(TAGCACHE_STATEFILE, O_RDONLY);
|
||||||
path, sizeof(path));
|
|
||||||
fd = open(file, O_RDONLY);
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
logf("no tagcache statedump");
|
logf("no tagcache statedump");
|
||||||
|
@ -3898,16 +3865,12 @@ static bool tagcache_dumpload(void)
|
||||||
static bool tagcache_dumpsave(void)
|
static bool tagcache_dumpsave(void)
|
||||||
{
|
{
|
||||||
struct statefile_header shdr;
|
struct statefile_header shdr;
|
||||||
char path[MAX_PATH];
|
|
||||||
const char *file;
|
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if (!tc_stat.ramcache)
|
if (!tc_stat.ramcache)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
file = get_user_file_path(TAGCACHE_STATEFILE, IS_FILE | NEED_WRITE,
|
fd = open(TAGCACHE_STATEFILE, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||||
path, sizeof(path));
|
|
||||||
fd = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
logf("failed to create a statedump");
|
logf("failed to create a statedump");
|
||||||
|
@ -3933,8 +3896,7 @@ static bool load_tagcache(void)
|
||||||
long bytesleft = tc_stat.ramcache_allocated;
|
long bytesleft = tc_stat.ramcache_allocated;
|
||||||
struct index_entry *idx;
|
struct index_entry *idx;
|
||||||
int rc, fd;
|
int rc, fd;
|
||||||
char *p, path[MAX_PATH];
|
char *p;
|
||||||
const char *file;
|
|
||||||
int i, tag;
|
int i, tag;
|
||||||
|
|
||||||
# ifdef HAVE_DIRCACHE
|
# ifdef HAVE_DIRCACHE
|
||||||
|
@ -3946,10 +3908,7 @@ static bool load_tagcache(void)
|
||||||
|
|
||||||
logf("loading tagcache to ram...");
|
logf("loading tagcache to ram...");
|
||||||
|
|
||||||
file = get_user_file_path(TAGCACHE_FILE_MASTER,
|
fd = open(TAGCACHE_FILE_MASTER, O_RDONLY);
|
||||||
IS_FILE|NEED_WRITE,
|
|
||||||
path, sizeof(path));
|
|
||||||
fd = open(file, O_RDONLY);
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
logf("tagcache open failed");
|
logf("tagcache open failed");
|
||||||
|
@ -4159,14 +4118,12 @@ static bool load_tagcache(void)
|
||||||
static bool check_deleted_files(void)
|
static bool check_deleted_files(void)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
char buf[TAG_MAXLEN+32], path[MAX_PATH];
|
char buf[TAG_MAXLEN+32];
|
||||||
const char *file;
|
|
||||||
struct tagfile_entry tfe;
|
struct tagfile_entry tfe;
|
||||||
|
|
||||||
logf("reverse scan...");
|
logf("reverse scan...");
|
||||||
snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, tag_filename);
|
snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, tag_filename);
|
||||||
file = get_user_file_path(buf, IS_FILE | NEED_WRITE, path, sizeof(path));
|
fd = open(buf, O_RDONLY);
|
||||||
fd = open(file, O_RDONLY);
|
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
|
@ -4326,8 +4283,6 @@ void tagcache_build(const char *path)
|
||||||
{
|
{
|
||||||
struct tagcache_header header;
|
struct tagcache_header header;
|
||||||
bool ret;
|
bool ret;
|
||||||
char buf[MAX_PATH];
|
|
||||||
const char *file;
|
|
||||||
|
|
||||||
curpath[0] = '\0';
|
curpath[0] = '\0';
|
||||||
data_size = 0;
|
data_size = 0;
|
||||||
|
@ -4341,20 +4296,18 @@ void tagcache_build(const char *path)
|
||||||
|
|
||||||
logf("updating tagcache");
|
logf("updating tagcache");
|
||||||
|
|
||||||
file = get_user_file_path(TAGCACHE_FILE_TEMP,
|
cachefd = open(TAGCACHE_FILE_TEMP, O_RDONLY);
|
||||||
IS_FILE|NEED_WRITE, buf, sizeof(buf));
|
if (cachefd >= 0)
|
||||||
|
|
||||||
|
|
||||||
if (file_exists(file))
|
|
||||||
{
|
{
|
||||||
logf("skipping, cache already waiting for commit");
|
logf("skipping, cache already waiting for commit");
|
||||||
|
close(cachefd);
|
||||||
return ;
|
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)
|
if (cachefd < 0)
|
||||||
{
|
{
|
||||||
logf("master file open failed: %s", file);
|
logf("master file open failed: %s", TAGCACHE_FILE_TEMP);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4398,7 +4351,7 @@ void tagcache_build(const char *path)
|
||||||
#endif
|
#endif
|
||||||
if (commit())
|
if (commit())
|
||||||
{
|
{
|
||||||
remove(file);
|
remove(TAGCACHE_FILE_TEMP);
|
||||||
logf("tagcache built!");
|
logf("tagcache built!");
|
||||||
}
|
}
|
||||||
#ifdef __PCTOOL__
|
#ifdef __PCTOOL__
|
||||||
|
@ -4443,12 +4396,7 @@ void tagcache_unload_ramcache(void)
|
||||||
{
|
{
|
||||||
tc_stat.ramcache = false;
|
tc_stat.ramcache = false;
|
||||||
/* Just to make sure there is no statefile present. */
|
/* Just to make sure there is no statefile present. */
|
||||||
|
// remove(TAGCACHE_STATEFILE);
|
||||||
#if 0
|
|
||||||
char path[MAX_PATH];
|
|
||||||
remove(get_user_file_path(TAGCACHE_STATEFILE, IS_FILE | NEED_WRITE,
|
|
||||||
path, sizeof(path)));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4457,7 +4405,6 @@ static void tagcache_thread(void)
|
||||||
{
|
{
|
||||||
struct queue_event ev;
|
struct queue_event ev;
|
||||||
bool check_done = false;
|
bool check_done = false;
|
||||||
char path[MAX_PATH];
|
|
||||||
|
|
||||||
/* If the previous cache build/update was interrupted, commit
|
/* If the previous cache build/update was interrupted, commit
|
||||||
* the changes first in foreground. */
|
* the changes first in foreground. */
|
||||||
|
@ -4474,8 +4421,7 @@ static void tagcache_thread(void)
|
||||||
check_done = tagcache_dumpload();
|
check_done = tagcache_dumpload();
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(get_user_file_path(TAGCACHE_STATEFILE, IS_FILE | NEED_WRITE,
|
remove(TAGCACHE_STATEFILE);
|
||||||
path, sizeof(path)));
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* Allocate space for the tagcache if found on disk. */
|
/* Allocate space for the tagcache if found on disk. */
|
||||||
|
@ -4508,8 +4454,7 @@ static void tagcache_thread(void)
|
||||||
|
|
||||||
case Q_REBUILD:
|
case Q_REBUILD:
|
||||||
remove_files();
|
remove_files();
|
||||||
remove(get_user_file_path(TAGCACHE_FILE_TEMP,
|
remove(TAGCACHE_FILE_TEMP);
|
||||||
IS_FILE|NEED_WRITE, path, sizeof(path)));
|
|
||||||
tagcache_build("/");
|
tagcache_build("/");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -261,8 +261,7 @@ static int tree_voice_cb(int selected_item, void * data)
|
||||||
|
|
||||||
bool check_rockboxdir(void)
|
bool check_rockboxdir(void)
|
||||||
{
|
{
|
||||||
char path[MAX_PATH];
|
if(!dir_exists(ROCKBOX_DIR))
|
||||||
if(!dir_exists(get_user_file_path(ROCKBOX_DIR, 0, path, sizeof(path))))
|
|
||||||
{ /* No need to localise this message.
|
{ /* No need to localise this message.
|
||||||
If .rockbox is missing, it wouldn't work anyway */
|
If .rockbox is missing, it wouldn't work anyway */
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -89,13 +89,10 @@ static int fdbind_idx = 0;
|
||||||
*/
|
*/
|
||||||
static int open_dircache_file(unsigned flags, int permissions)
|
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)
|
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)
|
static int remove_dircache_file(void)
|
||||||
{
|
{
|
||||||
char path[MAX_PATH];
|
return remove(DIRCACHE_FILE);
|
||||||
return remove(get_user_file_path(DIRCACHE_FILE, IS_FILE|NEED_WRITE,
|
|
||||||
path, sizeof(path)));
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,13 +22,47 @@
|
||||||
|
|
||||||
#include <stdio.h> /* snprintf */
|
#include <stdio.h> /* snprintf */
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include "rbpaths.h"
|
#include "rbpaths.h"
|
||||||
#include "file.h" /* MAX_PATH */
|
#include "file.h" /* MAX_PATH */
|
||||||
#include "dir.h"
|
|
||||||
#include "gcc_extensions.h"
|
#include "gcc_extensions.h"
|
||||||
#include "string-extra.h"
|
#include "string-extra.h"
|
||||||
#include "filefuncs.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)
|
void paths_init(void)
|
||||||
{
|
{
|
||||||
|
@ -42,14 +76,28 @@ void paths_init(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* get_user_file_path(const char *path,
|
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,
|
unsigned flags,
|
||||||
char* buf,
|
char* buf,
|
||||||
const size_t bufsize)
|
const size_t bufsize)
|
||||||
{
|
{
|
||||||
const char *ret = path;
|
const char *ret = path;
|
||||||
const char *pos = path;
|
const char *pos = path;
|
||||||
printf("%s(): looking for %s\n", __func__, path);
|
|
||||||
/* replace ROCKBOX_DIR in path with $HOME/.config/rockbox.org */
|
/* replace ROCKBOX_DIR in path with $HOME/.config/rockbox.org */
|
||||||
pos += ROCKBOX_DIR_LEN;
|
pos += ROCKBOX_DIR_LEN;
|
||||||
if (*pos == '/') pos += 1;
|
if (*pos == '/') pos += 1;
|
||||||
|
@ -66,27 +114,99 @@ const char* get_user_file_path(const char *path,
|
||||||
* write access is needed */
|
* write access is needed */
|
||||||
if (flags & NEED_WRITE)
|
if (flags & NEED_WRITE)
|
||||||
ret = buf;
|
ret = buf;
|
||||||
else
|
else if (try_path(buf, flags))
|
||||||
{
|
|
||||||
if (flags & IS_FILE)
|
|
||||||
{
|
|
||||||
if (file_exists(buf))
|
|
||||||
ret = buf;
|
ret = buf;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (dir_exists(buf))
|
|
||||||
ret = buf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* make a copy if we're about to return the path*/
|
if (ret != buf) /* not found in $HOME, try ROCKBOX_BASE_DIR, !NEED_WRITE only */
|
||||||
if (UNLIKELY((flags & FORCE_BUFFER_COPY) && (ret != buf)))
|
|
||||||
{
|
{
|
||||||
strlcpy(buf, ret, bufsize);
|
if (snprintf(buf, bufsize, ROCKBOX_SHARE_PATH "/%s", pos) >= (int)bufsize)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (try_path(buf, flags))
|
||||||
ret = buf;
|
ret = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%s(): %s\n", __func__, ret);
|
|
||||||
return ret;
|
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))
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,17 +26,6 @@
|
||||||
#include "autoconf.h"
|
#include "autoconf.h"
|
||||||
#include "string-extra.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
|
/* name of directory where configuration, fonts and other data
|
||||||
* files are stored */
|
* files are stored */
|
||||||
|
@ -67,35 +56,17 @@
|
||||||
#define REC_BASE_DIR "/"
|
#define REC_BASE_DIR "/"
|
||||||
#define PLAYLIST_CATALOG_DEFAULT_DIR "/Playlists"
|
#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()
|
#define paths_init()
|
||||||
#else /* application */
|
#else /* application */
|
||||||
|
|
||||||
#define PLUGIN_DIR ROCKBOX_LIBRARY_PATH "/rockbox/rocks"
|
#define PLUGIN_DIR ROCKBOX_LIBRARY_PATH "/rocks"
|
||||||
#define CODECS_DIR ROCKBOX_LIBRARY_PATH "/rockbox/codecs"
|
#define CODECS_DIR ROCKBOX_LIBRARY_PATH "/codecs"
|
||||||
|
|
||||||
#define REC_BASE_DIR ROCKBOX_DIR "/"
|
#define REC_BASE_DIR ROCKBOX_DIR "/"
|
||||||
#define PLAYLIST_CATALOG_DEFAULT_DIR ROCKBOX_DIR "/Playlists"
|
#define PLAYLIST_CATALOG_DEFAULT_DIR ROCKBOX_DIR "/Playlists"
|
||||||
|
|
||||||
extern void paths_init(void);
|
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 */
|
#endif /* APPLICATION */
|
||||||
|
|
||||||
#define LANG_DIR ROCKBOX_DIR "/langs"
|
#define LANG_DIR ROCKBOX_DIR "/langs"
|
||||||
|
|
|
@ -613,11 +613,7 @@ void glyph_cache_save(struct font* pf)
|
||||||
pf = &font_ui;
|
pf = &font_ui;
|
||||||
if (pf->fd >= 0 && pf == &font_ui)
|
if (pf->fd >= 0 && pf == &font_ui)
|
||||||
{
|
{
|
||||||
char path[MAX_PATH];
|
cache_fd = open(GLYPH_CACHE_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0666);
|
||||||
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);
|
|
||||||
if (cache_fd < 0)
|
if (cache_fd < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -678,7 +674,6 @@ static void glyph_cache_load(struct font* pf)
|
||||||
int i, size;
|
int i, size;
|
||||||
unsigned char tmp[2];
|
unsigned char tmp[2];
|
||||||
unsigned short ch;
|
unsigned short ch;
|
||||||
char path[MAX_PATH];
|
|
||||||
unsigned short glyphs[MAX_SORT];
|
unsigned short glyphs[MAX_SORT];
|
||||||
unsigned short glyphs_lru_order[MAX_SORT];
|
unsigned short glyphs_lru_order[MAX_SORT];
|
||||||
int glyph_file_skip=0, glyph_file_size=0;
|
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 )
|
if ( sort_size > MAX_SORT )
|
||||||
sort_size = MAX_SORT;
|
sort_size = MAX_SORT;
|
||||||
|
|
||||||
fd = open(get_user_file_path(GLYPH_CACHE_FILE, IS_FILE|NEED_WRITE,
|
fd = open(GLYPH_CACHE_FILE, O_RDONLY|O_BINARY);
|
||||||
path, sizeof(path)), O_RDONLY|O_BINARY);
|
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
|
|
||||||
/* only read what fits */
|
/* only read what fits */
|
||||||
|
|
|
@ -49,7 +49,6 @@
|
||||||
#define ATTR_ARCHIVE 0x20
|
#define ATTR_ARCHIVE 0x20
|
||||||
#define ATTR_VOLUME 0x40 /* this is a volume, not a real directory */
|
#define ATTR_VOLUME 0x40 /* this is a volume, not a real directory */
|
||||||
|
|
||||||
#if (CONFIG_PLATFORM & (PLATFORM_NATIVE|PLATFORM_SDL))
|
|
||||||
#ifdef HAVE_DIRCACHE
|
#ifdef HAVE_DIRCACHE
|
||||||
# include "dircache.h"
|
# include "dircache.h"
|
||||||
# define DIR DIR_CACHED
|
# define DIR DIR_CACHED
|
||||||
|
@ -71,9 +70,5 @@
|
||||||
# define mkdir mkdir_uncached
|
# define mkdir mkdir_uncached
|
||||||
# define rmdir rmdir_uncached
|
# define rmdir rmdir_uncached
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
#include "dir-target.h"
|
|
||||||
#include "dir_uncached.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -54,6 +54,7 @@ struct dirent_uncached {
|
||||||
|
|
||||||
#include "fat.h"
|
#include "fat.h"
|
||||||
|
|
||||||
|
#ifndef DIR_DEFINED
|
||||||
typedef struct {
|
typedef struct {
|
||||||
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
|
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
|
||||||
bool busy;
|
bool busy;
|
||||||
|
@ -69,6 +70,24 @@ typedef struct {
|
||||||
char *name;
|
char *name;
|
||||||
#endif
|
#endif
|
||||||
} DIR_UNCACHED;
|
} 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
|
#ifdef HAVE_HOTSWAP
|
||||||
char *get_volume_name(int volume);
|
char *get_volume_name(int volume);
|
||||||
|
|
|
@ -37,7 +37,25 @@
|
||||||
#define MAX_OPEN_FILES 11
|
#define MAX_OPEN_FILES 11
|
||||||
|
|
||||||
#if !defined(PLUGIN) && !defined(CODEC)
|
#if !defined(PLUGIN) && !defined(CODEC)
|
||||||
|
#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)
|
# 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 open(x, ...) sim_open(x, __VA_ARGS__)
|
||||||
# define creat(x,m) sim_creat(x,m)
|
# define creat(x,m) sim_creat(x,m)
|
||||||
# define remove(x) sim_remove(x)
|
# define remove(x) sim_remove(x)
|
||||||
|
@ -49,8 +67,8 @@
|
||||||
# define read(x,y,z) sim_read(x,y,z)
|
# define read(x,y,z) sim_read(x,y,z)
|
||||||
# define write(x,y,z) sim_write(x,y,z)
|
# define write(x,y,z) sim_write(x,y,z)
|
||||||
# define close(x) sim_close(x)
|
# define close(x) sim_close(x)
|
||||||
extern int sim_creat(const char *pathname, mode_t mode);
|
extern int sim_open(const char *name, int o, ...);
|
||||||
extern int sim_open(const char *pathname, int flags, ...);
|
extern int sim_creat(const char *name, mode_t mode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef int (*open_func)(const char* pathname, int flags, ...);
|
typedef int (*open_func)(const char* pathname, int flags, ...);
|
||||||
|
|
|
@ -144,17 +144,15 @@ void *lc_open_from_mem(void *addr, size_t blob_size)
|
||||||
for (i = 0; i < 10; i++)
|
for (i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
|
#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
|
* gives us the folder on the sdcard where we cannot load libraries
|
||||||
* from (no exec permissions)
|
* from (no exec permissions)
|
||||||
*/
|
*/
|
||||||
snprintf(temp_filename, sizeof(temp_filename),
|
snprintf(temp_filename, sizeof(temp_filename),
|
||||||
"/data/data/org.rockbox/app_rockbox/libtemp_binary_%d.so", i);
|
"/data/data/org.rockbox/app_rockbox/libtemp_binary_%d.so", i);
|
||||||
#else
|
#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),
|
snprintf(temp_filename, sizeof(temp_filename),
|
||||||
"%s/libtemp_binary_%d.dll", _name, i);
|
ROCKBOX_DIR "/libtemp_binary_%d.dll", i);
|
||||||
#endif
|
#endif
|
||||||
fd = open(temp_filename, O_WRONLY|O_CREAT|O_TRUNC, 0700);
|
fd = open(temp_filename, O_WRONLY|O_CREAT|O_TRUNC, 0700);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
|
|
|
@ -24,10 +24,21 @@
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
#define opendir _opendir
|
#define dirent_uncached dirent
|
||||||
#define mkdir _mkdir
|
#define DIR_UNCACHED DIR
|
||||||
#define closedir _closedir
|
#define opendir_uncached _opendir
|
||||||
#define readdir _readdir
|
#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 DIR* _opendir(const char* name);
|
||||||
extern int _mkdir(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);
|
extern void fat_size(unsigned long *size, unsigned long *free);
|
||||||
|
|
||||||
#define DIRFUNCTIONS_DEFINED
|
#define DIRFUNCTIONS_DEFINED
|
||||||
|
#define DIRENT_DEFINED
|
||||||
|
#define DIR_DEFINED
|
||||||
|
|
||||||
#endif /* __DIR_TARGET_H__ */
|
#endif /* __DIR_TARGET_H__ */
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "dir-target.h"
|
#include "dir-target.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "dir.h"
|
#include "dir.h"
|
||||||
|
#include "rbpaths.h"
|
||||||
|
|
||||||
|
|
||||||
long filesize(int fd)
|
long filesize(int fd)
|
||||||
|
|
|
@ -293,7 +293,6 @@ static const char *get_sim_pathname(const char *name)
|
||||||
MYDIR *sim_opendir(const char *name)
|
MYDIR *sim_opendir(const char *name)
|
||||||
{
|
{
|
||||||
DIR_T *dir;
|
DIR_T *dir;
|
||||||
|
|
||||||
dir = (DIR_T *) OPENDIR(get_sim_pathname(name));
|
dir = (DIR_T *) OPENDIR(get_sim_pathname(name));
|
||||||
|
|
||||||
if (dir)
|
if (dir)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue