diff options
author | Thomas Martitz <kugel@rockbox.org> | 2010-12-06 22:26:31 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2010-12-06 22:26:31 +0000 |
commit | 2c2416094f426972c9e2e96d25058311bbe82f97 (patch) | |
tree | 449b4e12e01c3c5c4afa2ae6a8cd396df82b5a38 /apps | |
parent | c35b43b0f54bd607d38908544446caaa02f148a3 (diff) | |
download | rockbox-2c2416094f426972c9e2e96d25058311bbe82f97.tar.gz rockbox-2c2416094f426972c9e2e96d25058311bbe82f97.zip |
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
Diffstat (limited to 'apps')
-rw-r--r-- | apps/filetypes.c | 8 | ||||
-rw-r--r-- | apps/gui/icon.c | 7 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_backdrops.c | 14 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_engine.c | 6 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_fonts.c | 4 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 3 | ||||
-rw-r--r-- | apps/main.c | 4 | ||||
-rw-r--r-- | apps/menus/theme_menu.c | 4 | ||||
-rw-r--r-- | apps/playlist.c | 10 | ||||
-rw-r--r-- | apps/playlist_catalog.c | 8 | ||||
-rw-r--r-- | apps/plugin.c | 6 | ||||
-rw-r--r-- | apps/settings.c | 36 | ||||
-rw-r--r-- | apps/tagcache.c | 145 | ||||
-rw-r--r-- | apps/tree.c | 3 |
14 files changed, 79 insertions, 179 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); | |||
219 | * load a colors file from a theme with: | 219 | * load a colors file from a theme with: |
220 | * filetype colours: filename.colours */ | 220 | * filetype colours: filename.colours */ |
221 | void read_color_theme_file(void) { | 221 | void read_color_theme_file(void) { |
222 | char buffer[MAX_PATH], dir[MAX_PATH]; | 222 | char buffer[MAX_PATH]; |
223 | int fd; | 223 | int fd; |
224 | char *ext, *color; | 224 | char *ext, *color; |
225 | int i; | 225 | int i; |
226 | for (i = 0; i < MAX_FILETYPES+1; i++) { | 226 | for (i = 0; i < MAX_FILETYPES+1; i++) { |
227 | custom_colors[i] = -1; | 227 | custom_colors[i] = -1; |
228 | } | 228 | } |
229 | snprintf(buffer, MAX_PATH, "%s/%s.colours", | 229 | snprintf(buffer, MAX_PATH, THEME_DIR "/%s.colours", |
230 | get_user_file_path(THEME_DIR, 0, dir, sizeof(dir)), | ||
231 | global_settings.colors_file); | 230 | global_settings.colors_file); |
232 | fd = open(buffer, O_RDONLY); | 231 | fd = open(buffer, O_RDONLY); |
233 | if (fd < 0) | 232 | if (fd < 0) |
@@ -300,7 +299,6 @@ void read_viewer_theme_file(void) | |||
300 | 299 | ||
301 | void filetype_init(void) | 300 | void filetype_init(void) |
302 | { | 301 | { |
303 | char path[MAX_PATH]; | ||
304 | /* set the directory item first */ | 302 | /* set the directory item first */ |
305 | filetypes[0].extension = NULL; | 303 | filetypes[0].extension = NULL; |
306 | filetypes[0].plugin = NULL; | 304 | filetypes[0].plugin = NULL; |
@@ -310,7 +308,7 @@ void filetype_init(void) | |||
310 | viewer_count = 0; | 308 | viewer_count = 0; |
311 | filetype_count = 1; | 309 | filetype_count = 1; |
312 | read_builtin_types(); | 310 | read_builtin_types(); |
313 | read_config(get_user_file_path(VIEWERS_CONFIG, IS_FILE, path, sizeof(path))); | 311 | read_config(VIEWERS_CONFIG); |
314 | #ifdef HAVE_LCD_BITMAP | 312 | #ifdef HAVE_LCD_BITMAP |
315 | read_viewer_theme_file(); | 313 | read_viewer_theme_file(); |
316 | #endif | 314 | #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) | |||
228 | if (filename[0] && filename[0] != '-') | 228 | if (filename[0] && filename[0] != '-') |
229 | { | 229 | { |
230 | char path[MAX_PATH]; | 230 | char path[MAX_PATH]; |
231 | char temp[MAX_PATH]; | ||
232 | const char * fname; | ||
233 | 231 | ||
234 | snprintf(path, sizeof(path), "%s/%s.bmp", ICON_DIR, filename); | 232 | snprintf(path, sizeof(path), ICON_DIR "/%s.bmp", filename); |
235 | fname = get_user_file_path(path, IS_FILE, temp, sizeof(temp)); | 233 | size_read = read_bmp_file(path, bmp, IMG_BUFSIZE, bmpformat, NULL); |
236 | size_read = read_bmp_file(fname, bmp, IMG_BUFSIZE, bmpformat, NULL); | ||
237 | if (size_read > 0) | 234 | if (size_read > 0) |
238 | { | 235 | { |
239 | *loaded_ok = true; | 236 | *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) | |||
54 | int skin_backdrop_assign(char* backdrop, char *bmpdir, | 54 | int skin_backdrop_assign(char* backdrop, char *bmpdir, |
55 | enum screen_type screen) | 55 | enum screen_type screen) |
56 | { | 56 | { |
57 | char dir[MAX_PATH]; | ||
58 | char filename[MAX_PATH]; | 57 | char filename[MAX_PATH]; |
59 | int i, free = -1; | 58 | int i, free = -1; |
60 | if (!backdrop) | 59 | if (!backdrop) |
@@ -68,8 +67,7 @@ int skin_backdrop_assign(char* backdrop, char *bmpdir, | |||
68 | } | 67 | } |
69 | else | 68 | else |
70 | { | 69 | { |
71 | const char *bd_dir = get_user_file_path(bmpdir, 0, dir, sizeof(dir)); | 70 | get_image_filename(backdrop, bmpdir, filename, sizeof(filename)); |
72 | get_image_filename(backdrop, bd_dir, filename, sizeof(filename)); | ||
73 | } | 71 | } |
74 | for (i=0; i<NB_BDROPS; i++) | 72 | for (i=0; i<NB_BDROPS; i++) |
75 | { | 73 | { |
@@ -115,12 +113,9 @@ bool skin_backdrops_preload(void) | |||
115 | if (screen == SCREEN_MAIN && global_settings.backdrop_file[0] && | 113 | if (screen == SCREEN_MAIN && global_settings.backdrop_file[0] && |
116 | global_settings.backdrop_file[0] != '-' && filename[0] == '-') | 114 | global_settings.backdrop_file[0] != '-' && filename[0] == '-') |
117 | { | 115 | { |
118 | char dir[MAX_PATH]; | ||
119 | char* temp = filename+2; /* slightly hacky to get a buffer */ | 116 | char* temp = filename+2; /* slightly hacky to get a buffer */ |
120 | size_t size = sizeof(backdrops[i].name) - 2; | 117 | size_t size = sizeof(backdrops[i].name) - 2; |
121 | snprintf(temp, size, "%s/%s.bmp", | 118 | snprintf(temp, size, BACKDROP_DIR "/%s.bmp", global_settings.backdrop_file); |
122 | get_user_file_path(BACKDROP_DIR, 0, dir, sizeof(dir)), | ||
123 | global_settings.backdrop_file); | ||
124 | filename = temp; | 119 | filename = temp; |
125 | } | 120 | } |
126 | if (*filename && *filename != '-') | 121 | if (*filename && *filename != '-') |
@@ -161,7 +156,7 @@ void skin_backdrop_unload(int backdrop_id) | |||
161 | void skin_backdrop_load_setting(void) | 156 | void skin_backdrop_load_setting(void) |
162 | { | 157 | { |
163 | int i; | 158 | int i; |
164 | char filename[MAX_PATH], dir[MAX_PATH]; | 159 | char filename[MAX_PATH]; |
165 | for(i=0;i<SKINNABLE_SCREENS_COUNT*NB_SCREENS;i++) | 160 | for(i=0;i<SKINNABLE_SCREENS_COUNT*NB_SCREENS;i++) |
166 | { | 161 | { |
167 | if (backdrops[i].name[0] == '-' && backdrops[i].screen == SCREEN_MAIN) | 162 | if (backdrops[i].name[0] == '-' && backdrops[i].screen == SCREEN_MAIN) |
@@ -171,8 +166,7 @@ void skin_backdrop_load_setting(void) | |||
171 | { | 166 | { |
172 | if (!backdrops[i].buffer) | 167 | if (!backdrops[i].buffer) |
173 | backdrops[i].buffer = (char*)skin_buffer_alloc(LCD_BACKDROP_BYTES); | 168 | backdrops[i].buffer = (char*)skin_buffer_alloc(LCD_BACKDROP_BYTES); |
174 | snprintf(filename, sizeof filename, "%s/%s.bmp", | 169 | snprintf(filename, sizeof filename, BACKDROP_DIR "/%s.bmp", |
175 | get_user_file_path(BACKDROP_DIR, 0, dir, sizeof(dir)), | ||
176 | global_settings.backdrop_file); | 170 | global_settings.backdrop_file); |
177 | bool loaded = backdrops[i].buffer && | 171 | bool loaded = backdrops[i].buffer && |
178 | screens[SCREEN_MAIN].backdrop_load(filename, | 172 | 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 | |||
155 | { | 155 | { |
156 | if (!loading_a_sbs && skins[skin][screen].data.wps_loaded == false) | 156 | if (!loading_a_sbs && skins[skin][screen].data.wps_loaded == false) |
157 | { | 157 | { |
158 | char buf[MAX_PATH*2], path[MAX_PATH]; | 158 | char buf[MAX_PATH*2]; |
159 | char *setting = NULL, *ext = NULL; | 159 | char *setting = NULL, *ext = NULL; |
160 | switch (skin) | 160 | switch (skin) |
161 | { | 161 | { |
@@ -226,9 +226,7 @@ struct gui_wps *skin_get_gwps(enum skinnable_screens skin, enum screen_type scre | |||
226 | buf[0] = '\0'; /* force it to reload the default */ | 226 | buf[0] = '\0'; /* force it to reload the default */ |
227 | if (strcmp(setting, "rockbox_failsafe")) | 227 | if (strcmp(setting, "rockbox_failsafe")) |
228 | { | 228 | { |
229 | snprintf(buf, sizeof buf, "%s/%s.%s", | 229 | snprintf(buf, sizeof buf, WPS_DIR "/%s.%s", setting, ext); |
230 | get_user_file_path(WPS_DIR, false, path, sizeof(path)), | ||
231 | setting, ext); | ||
232 | } | 230 | } |
233 | cpu_boost(true); | 231 | cpu_boost(true); |
234 | skin_load(skin, screen, buf, true); | 232 | 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) | |||
64 | struct font *pf; | 64 | struct font *pf; |
65 | struct skin_font_info *font = NULL; | 65 | struct skin_font_info *font = NULL; |
66 | char filename[MAX_PATH]; | 66 | char filename[MAX_PATH]; |
67 | char tmp[MAX_PATH]; | ||
68 | 67 | ||
69 | if (!strcmp(font_name, global_settings.font_file)) | 68 | if (!strcmp(font_name, global_settings.font_file)) |
70 | return FONT_UI; | 69 | return FONT_UI; |
@@ -72,8 +71,7 @@ int skin_font_load(char* font_name, int glyphs) | |||
72 | if (!strcmp(font_name, global_settings.remote_font_file)) | 71 | if (!strcmp(font_name, global_settings.remote_font_file)) |
73 | return FONT_UI_REMOTE; | 72 | return FONT_UI_REMOTE; |
74 | #endif | 73 | #endif |
75 | snprintf(tmp, MAX_PATH, FONT_DIR "/%s.fnt", font_name); | 74 | snprintf(filename, MAX_PATH, FONT_DIR "/%s.fnt", font_name); |
76 | get_user_file_path(tmp, FORCE_BUFFER_COPY, filename, sizeof(filename)); | ||
77 | 75 | ||
78 | for(i=0;i<MAXUSERFONTS;i++) | 76 | for(i=0;i<MAXUSERFONTS;i++) |
79 | { | 77 | { |
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, | |||
1646 | strlcpy(bmpdir, buf, dot - buf + 1); | 1646 | strlcpy(bmpdir, buf, dot - buf + 1); |
1647 | } | 1647 | } |
1648 | else | 1648 | else |
1649 | { /* fall back to backdrop dir for built-in themes */ | 1649 | { |
1650 | /* no get_user_file_path(), assuming we ship bmps for built-in themes */ | ||
1651 | snprintf(bmpdir, MAX_PATH, "%s", BACKDROP_DIR); | 1650 | snprintf(bmpdir, MAX_PATH, "%s", BACKDROP_DIR); |
1652 | } | 1651 | } |
1653 | /* load the bitmaps that were found by the parsing */ | 1652 | /* 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) | |||
172 | #ifdef AUTOROCK | 172 | #ifdef AUTOROCK |
173 | { | 173 | { |
174 | char filename[MAX_PATH]; | 174 | char filename[MAX_PATH]; |
175 | const char *file = get_user_file_path( | 175 | const char *file = |
176 | #ifdef APPLICATION | 176 | #ifdef APPLICATION |
177 | ROCKBOX_DIR | 177 | ROCKBOX_DIR |
178 | #else | 178 | #else |
179 | PLUGIN_APPS_DIR | 179 | PLUGIN_APPS_DIR |
180 | #endif | 180 | #endif |
181 | "/autostart.rock", NEED_WRITE|IS_FILE, filename, sizeof(filename)); | 181 | "/autostart.rock"; |
182 | if(file_exists(file)) /* no complaint if it doesn't exist */ | 182 | if(file_exists(file)) /* no complaint if it doesn't exist */ |
183 | { | 183 | { |
184 | plugin_load(file, NULL); /* start if it does */ | 184 | 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}; | |||
246 | 246 | ||
247 | int browse_folder(void *param) | 247 | int browse_folder(void *param) |
248 | { | 248 | { |
249 | char path[MAX_PATH]; | ||
250 | const struct browse_folder_info *info = | 249 | const struct browse_folder_info *info = |
251 | (const struct browse_folder_info*)param; | 250 | (const struct browse_folder_info*)param; |
252 | return rockbox_browse(get_user_file_path(info->dir, 0, path, sizeof(path)), | 251 | return rockbox_browse(info->dir, info->show_options); |
253 | info->show_options); | ||
254 | } | 252 | } |
255 | 253 | ||
256 | #ifdef HAVE_LCD_BITMAP | 254 | #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) | |||
1439 | /* process random folder advance */ | 1439 | /* process random folder advance */ |
1440 | if (global_settings.next_folder == FOLDER_ADVANCE_RANDOM) | 1440 | if (global_settings.next_folder == FOLDER_ADVANCE_RANDOM) |
1441 | { | 1441 | { |
1442 | char folder_advance_list[MAX_PATH]; | 1442 | int fd = open(ROCKBOX_DIR "/folder_advance_list.dat", O_RDONLY); |
1443 | get_user_file_path(ROCKBOX_DIR, FORCE_BUFFER_COPY, | ||
1444 | folder_advance_list, sizeof(folder_advance_list)); | ||
1445 | strlcat(folder_advance_list, "/folder_advance_list.dat", | ||
1446 | sizeof(folder_advance_list)); | ||
1447 | int fd = open(folder_advance_list, O_RDONLY); | ||
1448 | if (fd >= 0) | 1443 | if (fd >= 0) |
1449 | { | 1444 | { |
1450 | char buffer[MAX_PATH]; | 1445 | char buffer[MAX_PATH]; |
@@ -1914,8 +1909,7 @@ void playlist_init(void) | |||
1914 | struct playlist_info* playlist = ¤t_playlist; | 1909 | struct playlist_info* playlist = ¤t_playlist; |
1915 | 1910 | ||
1916 | playlist->current = true; | 1911 | playlist->current = true; |
1917 | get_user_file_path(PLAYLIST_CONTROL_FILE, IS_FILE|NEED_WRITE|FORCE_BUFFER_COPY, | 1912 | strlcpy(playlist->control_filename, PLAYLIST_CONTROL_FILE, |
1918 | playlist->control_filename, | ||
1919 | sizeof(playlist->control_filename)); | 1913 | sizeof(playlist->control_filename)); |
1920 | playlist->fd = -1; | 1914 | playlist->fd = -1; |
1921 | playlist->control_fd = -1; | 1915 | 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) | |||
81 | /* fall back to default directory if no or invalid config */ | 81 | /* fall back to default directory if no or invalid config */ |
82 | if (default_dir) | 82 | if (default_dir) |
83 | { | 83 | { |
84 | const char *dir = get_user_file_path(PLAYLIST_CATALOG_DEFAULT_DIR, | 84 | strcpy(playlist_dir, PLAYLIST_CATALOG_DEFAULT_DIR); |
85 | FORCE_BUFFER_COPY|NEED_WRITE, | 85 | if (!dir_exists(playlist_dir)) |
86 | playlist_dir, sizeof(playlist_dir)); | 86 | mkdir(playlist_dir); |
87 | if (!dir_exists(dir)) | ||
88 | mkdir(dir); | ||
89 | } | 87 | } |
90 | 88 | ||
91 | playlist_dir_length = strlen(playlist_dir); | 89 | 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 = { | |||
314 | #ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE | 314 | #ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE |
315 | (creat_func)creat_wrapper, | 315 | (creat_func)creat_wrapper, |
316 | #else | 316 | #else |
317 | (creat_func)PREFIX(creat), | 317 | (creat_func)creat, |
318 | #endif | 318 | #endif |
319 | (write_func)PREFIX(write), | 319 | (write_func)PREFIX(write), |
320 | PREFIX(remove), | 320 | remove, |
321 | PREFIX(rename), | 321 | rename, |
322 | PREFIX(ftruncate), | 322 | PREFIX(ftruncate), |
323 | PREFIX(filesize), | 323 | PREFIX(filesize), |
324 | fdprintf, | 324 | 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) | |||
118 | unsigned crc32 = 0xffffffff; | 118 | unsigned crc32 = 0xffffffff; |
119 | int var_count = 0, i = 0, buf_pos = 0; | 119 | int var_count = 0, i = 0, buf_pos = 0; |
120 | #ifndef HAVE_RTC_RAM | 120 | #ifndef HAVE_RTC_RAM |
121 | char path[MAX_PATH]; | 121 | int fd = open(NVRAM_FILE, O_RDONLY); |
122 | int fd = open(get_user_file_path(NVRAM_FILE, IS_FILE|NEED_WRITE, | ||
123 | path, sizeof(path)), O_RDONLY); | ||
124 | int bytes; | 122 | int bytes; |
125 | if (fd < 0) | 123 | if (fd < 0) |
126 | return false; | 124 | return false; |
@@ -174,7 +172,6 @@ static bool write_nvram_data(char* buf, int max_len) | |||
174 | char var_count = 0; | 172 | char var_count = 0; |
175 | #ifndef HAVE_RTC_RAM | 173 | #ifndef HAVE_RTC_RAM |
176 | int fd; | 174 | int fd; |
177 | char path[MAX_PATH]; | ||
178 | #endif | 175 | #endif |
179 | memset(buf,0,max_len); | 176 | memset(buf,0,max_len); |
180 | /* magic, version */ | 177 | /* magic, version */ |
@@ -198,8 +195,7 @@ static bool write_nvram_data(char* buf, int max_len) | |||
198 | max_len-NVRAM_DATA_START-1,0xffffffff); | 195 | max_len-NVRAM_DATA_START-1,0xffffffff); |
199 | memcpy(&buf[4],&crc32,4); | 196 | memcpy(&buf[4],&crc32,4); |
200 | #ifndef HAVE_RTC_RAM | 197 | #ifndef HAVE_RTC_RAM |
201 | fd = open(get_user_file_path(NVRAM_FILE, IS_FILE|NEED_WRITE, | 198 | fd = open(NVRAM_FILE,O_CREAT|O_TRUNC|O_WRONLY, 0666); |
202 | path, sizeof(path)),O_CREAT|O_TRUNC|O_WRONLY, 0666); | ||
203 | if (fd >= 0) | 199 | if (fd >= 0) |
204 | { | 200 | { |
205 | int len = write(fd,buf,max_len); | 201 | int len = write(fd,buf,max_len); |
@@ -230,12 +226,8 @@ void settings_load(int which) | |||
230 | read_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE); | 226 | read_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE); |
231 | if (which&SETTINGS_HD) | 227 | if (which&SETTINGS_HD) |
232 | { | 228 | { |
233 | const char *file; | 229 | settings_load_config(CONFIGFILE, false); |
234 | char path[MAX_PATH]; | 230 | settings_load_config(FIXEDSETTINGSFILE, false); |
235 | file = get_user_file_path(CONFIGFILE, IS_FILE|NEED_WRITE, path, sizeof(path)); | ||
236 | settings_load_config(file, false); | ||
237 | file = get_user_file_path(FIXEDSETTINGSFILE, IS_FILE, path, sizeof(path)); | ||
238 | settings_load_config(file, false); | ||
239 | } | 231 | } |
240 | } | 232 | } |
241 | 233 | ||
@@ -596,11 +588,8 @@ static void flush_global_status_callback(void *data) | |||
596 | static void flush_config_block_callback(void *data) | 588 | static void flush_config_block_callback(void *data) |
597 | { | 589 | { |
598 | (void)data; | 590 | (void)data; |
599 | char path[MAX_PATH]; | ||
600 | write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE); | 591 | write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE); |
601 | settings_write_config( | 592 | settings_write_config(CONFIGFILE, SETTINGS_SAVE_CHANGED); |
602 | get_user_file_path(CONFIGFILE, IS_FILE|NEED_WRITE, path, sizeof(path)), | ||
603 | SETTINGS_SAVE_CHANGED); | ||
604 | } | 593 | } |
605 | 594 | ||
606 | /* | 595 | /* |
@@ -644,7 +633,7 @@ int settings_save(void) | |||
644 | 633 | ||
645 | bool settings_save_config(int options) | 634 | bool settings_save_config(int options) |
646 | { | 635 | { |
647 | char filename[MAX_PATH], path[MAX_PATH]; | 636 | char filename[MAX_PATH]; |
648 | const char *folder, *namebase; | 637 | const char *folder, *namebase; |
649 | switch (options) | 638 | switch (options) |
650 | { | 639 | { |
@@ -673,8 +662,6 @@ bool settings_save_config(int options) | |||
673 | namebase = "config"; | 662 | namebase = "config"; |
674 | break; | 663 | break; |
675 | } | 664 | } |
676 | |||
677 | folder = get_user_file_path(folder, NEED_WRITE, path, sizeof(path)); | ||
678 | create_numbered_filename(filename, folder, namebase, ".cfg", 2 | 665 | create_numbered_filename(filename, folder, namebase, ".cfg", 2 |
679 | IF_CNFN_NUM_(, NULL)); | 666 | IF_CNFN_NUM_(, NULL)); |
680 | 667 | ||
@@ -884,13 +871,11 @@ void settings_apply(bool read_disk) | |||
884 | { | 871 | { |
885 | char buf[MAX_PATH]; | 872 | char buf[MAX_PATH]; |
886 | #ifdef HAVE_LCD_BITMAP | 873 | #ifdef HAVE_LCD_BITMAP |
887 | char dir[MAX_PATH]; | ||
888 | const char *font_path = get_user_file_path(FONT_DIR, 0, dir, sizeof(dir)); | ||
889 | /* fonts need to be loaded before the WPS */ | 874 | /* fonts need to be loaded before the WPS */ |
890 | if (global_settings.font_file[0] | 875 | if (global_settings.font_file[0] |
891 | && global_settings.font_file[0] != '-') { | 876 | && global_settings.font_file[0] != '-') { |
892 | 877 | ||
893 | snprintf(buf, sizeof buf, "%s/%s.fnt", font_path, | 878 | snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", |
894 | global_settings.font_file); | 879 | global_settings.font_file); |
895 | CHART2(">font_load ", global_settings.font_file); | 880 | CHART2(">font_load ", global_settings.font_file); |
896 | rc = font_load(NULL, buf); | 881 | rc = font_load(NULL, buf); |
@@ -903,7 +888,7 @@ void settings_apply(bool read_disk) | |||
903 | #ifdef HAVE_REMOTE_LCD | 888 | #ifdef HAVE_REMOTE_LCD |
904 | if ( global_settings.remote_font_file[0] | 889 | if ( global_settings.remote_font_file[0] |
905 | && global_settings.remote_font_file[0] != '-') { | 890 | && global_settings.remote_font_file[0] != '-') { |
906 | snprintf(buf, sizeof buf, "%s/%s.fnt", font_path, | 891 | snprintf(buf, sizeof buf, FONT_DIR "%s.fnt", |
907 | global_settings.remote_font_file); | 892 | global_settings.remote_font_file); |
908 | CHART2(">font_load_remoteui ", global_settings.remote_font_file); | 893 | CHART2(">font_load_remoteui ", global_settings.remote_font_file); |
909 | rc = font_load_remoteui(buf); | 894 | rc = font_load_remoteui(buf); |
@@ -915,8 +900,7 @@ void settings_apply(bool read_disk) | |||
915 | font_load_remoteui(NULL); | 900 | font_load_remoteui(NULL); |
916 | #endif | 901 | #endif |
917 | if ( global_settings.kbd_file[0]) { | 902 | if ( global_settings.kbd_file[0]) { |
918 | snprintf(buf, sizeof buf, "%s/%s.kbd", | 903 | snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd", |
919 | get_user_file_path(ROCKBOX_DIR, 0, dir, sizeof(dir)), | ||
920 | global_settings.kbd_file); | 904 | global_settings.kbd_file); |
921 | CHART(">load_kbd"); | 905 | CHART(">load_kbd"); |
922 | load_kbd(buf); | 906 | load_kbd(buf); |
@@ -925,8 +909,6 @@ void settings_apply(bool read_disk) | |||
925 | else | 909 | else |
926 | load_kbd(NULL); | 910 | load_kbd(NULL); |
927 | #endif /* HAVE_LCD_BITMAP */ | 911 | #endif /* HAVE_LCD_BITMAP */ |
928 | /* no get_user_file_path() here because we don't really support | ||
929 | * langs that don't come with rockbox */ | ||
930 | if ( global_settings.lang_file[0]) { | 912 | if ( global_settings.lang_file[0]) { |
931 | snprintf(buf, sizeof buf, LANG_DIR "/%s.lng", | 913 | snprintf(buf, sizeof buf, LANG_DIR "/%s.lng", |
932 | global_settings.lang_file); | 914 | 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 @@ | |||
73 | #include "buffer.h" | 73 | #include "buffer.h" |
74 | #include "crc32.h" | 74 | #include "crc32.h" |
75 | #include "misc.h" | 75 | #include "misc.h" |
76 | #include "filefuncs.h" | ||
77 | #include "settings.h" | 76 | #include "settings.h" |
78 | #include "dir.h" | 77 | #include "dir.h" |
78 | #include "filefuncs.h" | ||
79 | #include "structec.h" | 79 | #include "structec.h" |
80 | 80 | ||
81 | #ifndef __PCTOOL__ | 81 | #ifndef __PCTOOL__ |
@@ -293,17 +293,15 @@ static bool is_dircache_intact(void) | |||
293 | static int open_tag_fd(struct tagcache_header *hdr, int tag, bool write) | 293 | static int open_tag_fd(struct tagcache_header *hdr, int tag, bool write) |
294 | { | 294 | { |
295 | int fd; | 295 | int fd; |
296 | char buf[MAX_PATH], path[MAX_PATH]; | 296 | char buf[MAX_PATH]; |
297 | const char * file; | ||
298 | int rc; | 297 | int rc; |
299 | 298 | ||
300 | if (TAGCACHE_IS_NUMERIC(tag) || tag < 0 || tag >= TAG_COUNT) | 299 | if (TAGCACHE_IS_NUMERIC(tag) || tag < 0 || tag >= TAG_COUNT) |
301 | return -1; | 300 | return -1; |
302 | 301 | ||
303 | snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, tag); | 302 | snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, tag); |
304 | file = get_user_file_path(buf, IS_FILE | NEED_WRITE, path, sizeof(path)); | ||
305 | 303 | ||
306 | fd = open(file, write ? O_RDWR : O_RDONLY); | 304 | fd = open(buf, write ? O_RDWR : O_RDONLY); |
307 | if (fd < 0) | 305 | if (fd < 0) |
308 | { | 306 | { |
309 | logf("tag file open failed: tag=%d write=%d file=%s", tag, write, buf); | 307 | 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) | |||
328 | { | 326 | { |
329 | int fd; | 327 | int fd; |
330 | int rc; | 328 | int rc; |
331 | char path[MAX_PATH]; | ||
332 | 329 | ||
333 | fd = open(get_user_file_path(TAGCACHE_FILE_MASTER, | 330 | fd = open(TAGCACHE_FILE_MASTER, write ? O_RDWR : O_RDONLY); |
334 | IS_FILE|NEED_WRITE, | ||
335 | path, sizeof(path)), | ||
336 | write ? O_RDWR : O_RDONLY); | ||
337 | if (fd < 0) | 331 | if (fd < 0) |
338 | { | 332 | { |
339 | logf("master file open failed for R/W"); | 333 | logf("master file open failed for R/W"); |
@@ -675,12 +669,10 @@ static bool open_files(struct tagcache_search *tcs, int tag) | |||
675 | { | 669 | { |
676 | if (tcs->idxfd[tag] < 0) | 670 | if (tcs->idxfd[tag] < 0) |
677 | { | 671 | { |
678 | char fn[MAX_PATH], path[MAX_PATH]; | 672 | char fn[MAX_PATH]; |
679 | const char *file; | ||
680 | 673 | ||
681 | snprintf(fn, sizeof fn, TAGCACHE_FILE_INDEX, tag); | 674 | snprintf(fn, sizeof fn, TAGCACHE_FILE_INDEX, tag); |
682 | file = get_user_file_path(fn, IS_FILE | NEED_WRITE, path, sizeof(path)); | 675 | tcs->idxfd[tag] = open(fn, O_RDONLY); |
683 | tcs->idxfd[tag] = open(file, O_RDONLY); | ||
684 | } | 676 | } |
685 | 677 | ||
686 | if (tcs->idxfd[tag] < 0) | 678 | if (tcs->idxfd[tag] < 0) |
@@ -1218,17 +1210,14 @@ static void remove_files(void) | |||
1218 | tc_stat.ready = false; | 1210 | tc_stat.ready = false; |
1219 | tc_stat.ramcache = false; | 1211 | tc_stat.ramcache = false; |
1220 | tc_stat.econ = false; | 1212 | tc_stat.econ = false; |
1221 | remove(get_user_file_path(TAGCACHE_FILE_MASTER, NEED_WRITE|IS_FILE, | 1213 | remove(TAGCACHE_FILE_MASTER); |
1222 | buf, sizeof(buf))); | ||
1223 | for (i = 0; i < TAG_COUNT; i++) | 1214 | for (i = 0; i < TAG_COUNT; i++) |
1224 | { | 1215 | { |
1225 | char buf2[MAX_PATH]; | ||
1226 | if (TAGCACHE_IS_NUMERIC(i)) | 1216 | if (TAGCACHE_IS_NUMERIC(i)) |
1227 | continue; | 1217 | continue; |
1228 | 1218 | ||
1229 | /* database_%d.tcd -> database_0.tcd */ | ||
1230 | snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, i); | 1219 | snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, i); |
1231 | remove(get_user_file_path(buf, NEED_WRITE | IS_FILE, buf2, sizeof(buf2))); | 1220 | remove(buf); |
1232 | } | 1221 | } |
1233 | } | 1222 | } |
1234 | 1223 | ||
@@ -1379,11 +1368,10 @@ bool tagcache_search_add_clause(struct tagcache_search *tcs, | |||
1379 | 1368 | ||
1380 | if (!TAGCACHE_IS_NUMERIC(clause->tag) && tcs->idxfd[clause->tag] < 0) | 1369 | if (!TAGCACHE_IS_NUMERIC(clause->tag) && tcs->idxfd[clause->tag] < 0) |
1381 | { | 1370 | { |
1382 | char buf[MAX_PATH], path[MAX_PATH]; | 1371 | char buf[MAX_PATH]; |
1383 | const char *file; | 1372 | |
1384 | snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, clause->tag); | 1373 | snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, clause->tag); |
1385 | file = get_user_file_path(buf, IS_FILE | NEED_WRITE, path, sizeof(path)); | 1374 | tcs->idxfd[clause->tag] = open(buf, O_RDONLY); |
1386 | tcs->idxfd[clause->tag] = open(file, O_RDONLY); | ||
1387 | } | 1375 | } |
1388 | 1376 | ||
1389 | tcs->clause[tcs->clause_count] = clause; | 1377 | tcs->clause[tcs->clause_count] = clause; |
@@ -2407,8 +2395,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd) | |||
2407 | struct master_header tcmh; | 2395 | struct master_header tcmh; |
2408 | struct index_entry idxbuf[IDX_BUF_DEPTH]; | 2396 | struct index_entry idxbuf[IDX_BUF_DEPTH]; |
2409 | int idxbuf_pos; | 2397 | int idxbuf_pos; |
2410 | char buf[TAG_MAXLEN+32], path[MAX_PATH]; | 2398 | char buf[TAG_MAXLEN+32]; |
2411 | const char *file; | ||
2412 | int fd = -1, masterfd; | 2399 | int fd = -1, masterfd; |
2413 | bool error = false; | 2400 | bool error = false; |
2414 | int init; | 2401 | int init; |
@@ -2556,8 +2543,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd) | |||
2556 | * anything whether the index type is sorted or not. | 2543 | * anything whether the index type is sorted or not. |
2557 | */ | 2544 | */ |
2558 | snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, index_type); | 2545 | snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, index_type); |
2559 | file = get_user_file_path(buf, IS_FILE | NEED_WRITE, path, sizeof(path)); | 2546 | fd = open(buf, O_WRONLY | O_CREAT | O_TRUNC, 0666); |
2560 | fd = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666); | ||
2561 | if (fd < 0) | 2547 | if (fd < 0) |
2562 | { | 2548 | { |
2563 | logf("%s open fail", buf); | 2549 | logf("%s open fail", buf); |
@@ -2577,21 +2563,18 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd) | |||
2577 | } | 2563 | } |
2578 | } | 2564 | } |
2579 | 2565 | ||
2580 | file = get_user_file_path(TAGCACHE_FILE_MASTER, | ||
2581 | IS_FILE|NEED_WRITE, | ||
2582 | buf, sizeof(buf)); | ||
2583 | /* Loading the tag lookup file as "master file". */ | 2566 | /* Loading the tag lookup file as "master file". */ |
2584 | logf("Loading index file"); | 2567 | logf("Loading index file"); |
2585 | masterfd = open(file, O_RDWR); | 2568 | masterfd = open(TAGCACHE_FILE_MASTER, O_RDWR); |
2586 | 2569 | ||
2587 | if (masterfd < 0) | 2570 | if (masterfd < 0) |
2588 | { | 2571 | { |
2589 | logf("Creating new DB"); | 2572 | logf("Creating new DB"); |
2590 | masterfd = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666); | 2573 | masterfd = open(TAGCACHE_FILE_MASTER, O_WRONLY | O_CREAT | O_TRUNC, 0666); |
2591 | 2574 | ||
2592 | if (masterfd < 0) | 2575 | if (masterfd < 0) |
2593 | { | 2576 | { |
2594 | logf("Failure to create index file (%s)", file); | 2577 | logf("Failure to create index file (%s)", TAGCACHE_FILE_MASTER); |
2595 | close(fd); | 2578 | close(fd); |
2596 | return -2; | 2579 | return -2; |
2597 | } | 2580 | } |
@@ -2899,8 +2882,6 @@ static bool commit(void) | |||
2899 | { | 2882 | { |
2900 | struct tagcache_header tch; | 2883 | struct tagcache_header tch; |
2901 | struct master_header tcmh; | 2884 | struct master_header tcmh; |
2902 | char path[MAX_PATH]; | ||
2903 | const char *file; | ||
2904 | int i, len, rc; | 2885 | int i, len, rc; |
2905 | int tmpfd; | 2886 | int tmpfd; |
2906 | int masterfd; | 2887 | int masterfd; |
@@ -2914,10 +2895,7 @@ static bool commit(void) | |||
2914 | while (write_lock) | 2895 | while (write_lock) |
2915 | sleep(1); | 2896 | sleep(1); |
2916 | 2897 | ||
2917 | file = get_user_file_path(TAGCACHE_FILE_TEMP, | 2898 | tmpfd = open(TAGCACHE_FILE_TEMP, O_RDONLY); |
2918 | IS_FILE|NEED_WRITE, path, sizeof(path)); | ||
2919 | |||
2920 | tmpfd = open(file, O_RDONLY); | ||
2921 | if (tmpfd < 0) | 2899 | if (tmpfd < 0) |
2922 | { | 2900 | { |
2923 | logf("nothing to commit"); | 2901 | logf("nothing to commit"); |
@@ -2933,7 +2911,7 @@ static bool commit(void) | |||
2933 | { | 2911 | { |
2934 | logf("incorrect tmpheader"); | 2912 | logf("incorrect tmpheader"); |
2935 | close(tmpfd); | 2913 | close(tmpfd); |
2936 | remove(file); | 2914 | remove(TAGCACHE_FILE_TEMP); |
2937 | return false; | 2915 | return false; |
2938 | } | 2916 | } |
2939 | 2917 | ||
@@ -2941,7 +2919,7 @@ static bool commit(void) | |||
2941 | { | 2919 | { |
2942 | logf("nothing to commit"); | 2920 | logf("nothing to commit"); |
2943 | close(tmpfd); | 2921 | close(tmpfd); |
2944 | remove(file); | 2922 | remove(TAGCACHE_FILE_TEMP); |
2945 | return true; | 2923 | return true; |
2946 | } | 2924 | } |
2947 | 2925 | ||
@@ -2949,8 +2927,7 @@ static bool commit(void) | |||
2949 | tc_stat.ready = check_all_headers(); | 2927 | tc_stat.ready = check_all_headers(); |
2950 | 2928 | ||
2951 | #ifdef HAVE_EEPROM_SETTINGS | 2929 | #ifdef HAVE_EEPROM_SETTINGS |
2952 | remove(get_user_file_path(TAGCACHE_STATEFILE, IS_FILE | NEED_WRITE, | 2930 | remove(TAGCACHE_STATEFILE); |
2953 | path, sizeof(path))); | ||
2954 | #endif | 2931 | #endif |
2955 | 2932 | ||
2956 | /* At first be sure to unload the ramcache! */ | 2933 | /* At first be sure to unload the ramcache! */ |
@@ -3040,7 +3017,7 @@ static bool commit(void) | |||
3040 | } | 3017 | } |
3041 | 3018 | ||
3042 | close(tmpfd); | 3019 | close(tmpfd); |
3043 | remove(file); | 3020 | remove(TAGCACHE_FILE_TEMP); |
3044 | 3021 | ||
3045 | tc_stat.commit_step = 0; | 3022 | tc_stat.commit_step = 0; |
3046 | 3023 | ||
@@ -3458,18 +3435,15 @@ bool tagcache_import_changelog(void) | |||
3458 | struct tagcache_header tch; | 3435 | struct tagcache_header tch; |
3459 | int clfd; | 3436 | int clfd; |
3460 | long masterfd; | 3437 | long masterfd; |
3461 | char buf[MAX(MAX_PATH, 2048)]; | 3438 | char buf[2048]; |
3462 | const char *file; | ||
3463 | 3439 | ||
3464 | if (!tc_stat.ready) | 3440 | if (!tc_stat.ready) |
3465 | return false; | 3441 | return false; |
3466 | 3442 | ||
3467 | while (read_lock) | 3443 | while (read_lock) |
3468 | sleep(1); | 3444 | sleep(1); |
3469 | 3445 | ||
3470 | file = get_user_file_path(TAGCACHE_FILE_CHANGELOG, | 3446 | clfd = open(TAGCACHE_FILE_CHANGELOG, O_RDONLY); |
3471 | IS_FILE|NEED_WRITE, buf, sizeof(buf)); | ||
3472 | clfd = open(file, O_RDONLY); | ||
3473 | if (clfd < 0) | 3447 | if (clfd < 0) |
3474 | { | 3448 | { |
3475 | logf("failure to open changelog"); | 3449 | logf("failure to open changelog"); |
@@ -3511,8 +3485,7 @@ bool tagcache_create_changelog(struct tagcache_search *tcs) | |||
3511 | { | 3485 | { |
3512 | struct master_header myhdr; | 3486 | struct master_header myhdr; |
3513 | struct index_entry idx; | 3487 | struct index_entry idx; |
3514 | const char *file; | 3488 | char buf[TAG_MAXLEN+32]; |
3515 | char buf[MAX(TAG_MAXLEN+32, MAX_PATH)]; | ||
3516 | char temp[32]; | 3489 | char temp[32]; |
3517 | int clfd; | 3490 | int clfd; |
3518 | int i, j; | 3491 | int i, j; |
@@ -3524,9 +3497,7 @@ bool tagcache_create_changelog(struct tagcache_search *tcs) | |||
3524 | return false; | 3497 | return false; |
3525 | 3498 | ||
3526 | /* Initialize the changelog */ | 3499 | /* Initialize the changelog */ |
3527 | file = get_user_file_path(TAGCACHE_FILE_CHANGELOG, IS_FILE | NEED_WRITE, | 3500 | clfd = open(TAGCACHE_FILE_CHANGELOG, O_WRONLY | O_CREAT | O_TRUNC, 0666); |
3528 | buf, sizeof(buf)); | ||
3529 | clfd = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666); | ||
3530 | if (clfd < 0) | 3501 | if (clfd < 0) |
3531 | { | 3502 | { |
3532 | logf("failure to open changelog"); | 3503 | logf("failure to open changelog"); |
@@ -3844,15 +3815,11 @@ static bool allocate_tagcache(void) | |||
3844 | static bool tagcache_dumpload(void) | 3815 | static bool tagcache_dumpload(void) |
3845 | { | 3816 | { |
3846 | struct statefile_header shdr; | 3817 | struct statefile_header shdr; |
3847 | char path[MAX_PATH]; | ||
3848 | const char *file; | ||
3849 | int fd, rc; | 3818 | int fd, rc; |
3850 | long offpos; | 3819 | long offpos; |
3851 | int i; | 3820 | int i; |
3852 | 3821 | ||
3853 | file = get_user_file_path(TAGCACHE_STATEFILE, IS_FILE | NEED_WRITE, | 3822 | fd = open(TAGCACHE_STATEFILE, O_RDONLY); |
3854 | path, sizeof(path)); | ||
3855 | fd = open(file, O_RDONLY); | ||
3856 | if (fd < 0) | 3823 | if (fd < 0) |
3857 | { | 3824 | { |
3858 | logf("no tagcache statedump"); | 3825 | logf("no tagcache statedump"); |
@@ -3898,16 +3865,12 @@ static bool tagcache_dumpload(void) | |||
3898 | static bool tagcache_dumpsave(void) | 3865 | static bool tagcache_dumpsave(void) |
3899 | { | 3866 | { |
3900 | struct statefile_header shdr; | 3867 | struct statefile_header shdr; |
3901 | char path[MAX_PATH]; | ||
3902 | const char *file; | ||
3903 | int fd; | 3868 | int fd; |
3904 | 3869 | ||
3905 | if (!tc_stat.ramcache) | 3870 | if (!tc_stat.ramcache) |
3906 | return false; | 3871 | return false; |
3907 | 3872 | ||
3908 | file = get_user_file_path(TAGCACHE_STATEFILE, IS_FILE | NEED_WRITE, | 3873 | fd = open(TAGCACHE_STATEFILE, O_WRONLY | O_CREAT | O_TRUNC, 0666); |
3909 | path, sizeof(path)); | ||
3910 | fd = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666); | ||
3911 | if (fd < 0) | 3874 | if (fd < 0) |
3912 | { | 3875 | { |
3913 | logf("failed to create a statedump"); | 3876 | logf("failed to create a statedump"); |
@@ -3933,8 +3896,7 @@ static bool load_tagcache(void) | |||
3933 | long bytesleft = tc_stat.ramcache_allocated; | 3896 | long bytesleft = tc_stat.ramcache_allocated; |
3934 | struct index_entry *idx; | 3897 | struct index_entry *idx; |
3935 | int rc, fd; | 3898 | int rc, fd; |
3936 | char *p, path[MAX_PATH]; | 3899 | char *p; |
3937 | const char *file; | ||
3938 | int i, tag; | 3900 | int i, tag; |
3939 | 3901 | ||
3940 | # ifdef HAVE_DIRCACHE | 3902 | # ifdef HAVE_DIRCACHE |
@@ -3945,11 +3907,8 @@ static bool load_tagcache(void) | |||
3945 | # endif | 3907 | # endif |
3946 | 3908 | ||
3947 | logf("loading tagcache to ram..."); | 3909 | logf("loading tagcache to ram..."); |
3948 | 3910 | ||
3949 | file = get_user_file_path(TAGCACHE_FILE_MASTER, | 3911 | fd = open(TAGCACHE_FILE_MASTER, O_RDONLY); |
3950 | IS_FILE|NEED_WRITE, | ||
3951 | path, sizeof(path)); | ||
3952 | fd = open(file, O_RDONLY); | ||
3953 | if (fd < 0) | 3912 | if (fd < 0) |
3954 | { | 3913 | { |
3955 | logf("tagcache open failed"); | 3914 | logf("tagcache open failed"); |
@@ -4159,14 +4118,12 @@ static bool load_tagcache(void) | |||
4159 | static bool check_deleted_files(void) | 4118 | static bool check_deleted_files(void) |
4160 | { | 4119 | { |
4161 | int fd; | 4120 | int fd; |
4162 | char buf[TAG_MAXLEN+32], path[MAX_PATH]; | 4121 | char buf[TAG_MAXLEN+32]; |
4163 | const char *file; | ||
4164 | struct tagfile_entry tfe; | 4122 | struct tagfile_entry tfe; |
4165 | 4123 | ||
4166 | logf("reverse scan..."); | 4124 | logf("reverse scan..."); |
4167 | snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, tag_filename); | 4125 | snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, tag_filename); |
4168 | file = get_user_file_path(buf, IS_FILE | NEED_WRITE, path, sizeof(path)); | 4126 | fd = open(buf, O_RDONLY); |
4169 | fd = open(file, O_RDONLY); | ||
4170 | 4127 | ||
4171 | if (fd < 0) | 4128 | if (fd < 0) |
4172 | { | 4129 | { |
@@ -4326,8 +4283,6 @@ void tagcache_build(const char *path) | |||
4326 | { | 4283 | { |
4327 | struct tagcache_header header; | 4284 | struct tagcache_header header; |
4328 | bool ret; | 4285 | bool ret; |
4329 | char buf[MAX_PATH]; | ||
4330 | const char *file; | ||
4331 | 4286 | ||
4332 | curpath[0] = '\0'; | 4287 | curpath[0] = '\0'; |
4333 | data_size = 0; | 4288 | data_size = 0; |
@@ -4340,21 +4295,19 @@ void tagcache_build(const char *path) | |||
4340 | #endif | 4295 | #endif |
4341 | 4296 | ||
4342 | logf("updating tagcache"); | 4297 | logf("updating tagcache"); |
4343 | |||
4344 | file = get_user_file_path(TAGCACHE_FILE_TEMP, | ||
4345 | IS_FILE|NEED_WRITE, buf, sizeof(buf)); | ||
4346 | 4298 | ||
4347 | 4299 | cachefd = open(TAGCACHE_FILE_TEMP, O_RDONLY); | |
4348 | if (file_exists(file)) | 4300 | if (cachefd >= 0) |
4349 | { | 4301 | { |
4350 | logf("skipping, cache already waiting for commit"); | 4302 | logf("skipping, cache already waiting for commit"); |
4303 | close(cachefd); | ||
4351 | return ; | 4304 | return ; |
4352 | } | 4305 | } |
4353 | 4306 | ||
4354 | cachefd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0666); | 4307 | cachefd = open(TAGCACHE_FILE_TEMP, O_RDWR | O_CREAT | O_TRUNC, 0666); |
4355 | if (cachefd < 0) | 4308 | if (cachefd < 0) |
4356 | { | 4309 | { |
4357 | logf("master file open failed: %s", file); | 4310 | logf("master file open failed: %s", TAGCACHE_FILE_TEMP); |
4358 | return ; | 4311 | return ; |
4359 | } | 4312 | } |
4360 | 4313 | ||
@@ -4398,7 +4351,7 @@ void tagcache_build(const char *path) | |||
4398 | #endif | 4351 | #endif |
4399 | if (commit()) | 4352 | if (commit()) |
4400 | { | 4353 | { |
4401 | remove(file); | 4354 | remove(TAGCACHE_FILE_TEMP); |
4402 | logf("tagcache built!"); | 4355 | logf("tagcache built!"); |
4403 | } | 4356 | } |
4404 | #ifdef __PCTOOL__ | 4357 | #ifdef __PCTOOL__ |
@@ -4443,12 +4396,7 @@ void tagcache_unload_ramcache(void) | |||
4443 | { | 4396 | { |
4444 | tc_stat.ramcache = false; | 4397 | tc_stat.ramcache = false; |
4445 | /* Just to make sure there is no statefile present. */ | 4398 | /* Just to make sure there is no statefile present. */ |
4446 | 4399 | // remove(TAGCACHE_STATEFILE); | |
4447 | #if 0 | ||
4448 | char path[MAX_PATH]; | ||
4449 | remove(get_user_file_path(TAGCACHE_STATEFILE, IS_FILE | NEED_WRITE, | ||
4450 | path, sizeof(path))); | ||
4451 | #endif | ||
4452 | } | 4400 | } |
4453 | #endif | 4401 | #endif |
4454 | 4402 | ||
@@ -4457,7 +4405,6 @@ static void tagcache_thread(void) | |||
4457 | { | 4405 | { |
4458 | struct queue_event ev; | 4406 | struct queue_event ev; |
4459 | bool check_done = false; | 4407 | bool check_done = false; |
4460 | char path[MAX_PATH]; | ||
4461 | 4408 | ||
4462 | /* If the previous cache build/update was interrupted, commit | 4409 | /* If the previous cache build/update was interrupted, commit |
4463 | * the changes first in foreground. */ | 4410 | * the changes first in foreground. */ |
@@ -4474,8 +4421,7 @@ static void tagcache_thread(void) | |||
4474 | check_done = tagcache_dumpload(); | 4421 | check_done = tagcache_dumpload(); |
4475 | } | 4422 | } |
4476 | 4423 | ||
4477 | remove(get_user_file_path(TAGCACHE_STATEFILE, IS_FILE | NEED_WRITE, | 4424 | remove(TAGCACHE_STATEFILE); |
4478 | path, sizeof(path))); | ||
4479 | # endif | 4425 | # endif |
4480 | 4426 | ||
4481 | /* Allocate space for the tagcache if found on disk. */ | 4427 | /* Allocate space for the tagcache if found on disk. */ |
@@ -4508,8 +4454,7 @@ static void tagcache_thread(void) | |||
4508 | 4454 | ||
4509 | case Q_REBUILD: | 4455 | case Q_REBUILD: |
4510 | remove_files(); | 4456 | remove_files(); |
4511 | remove(get_user_file_path(TAGCACHE_FILE_TEMP, | 4457 | remove(TAGCACHE_FILE_TEMP); |
4512 | IS_FILE|NEED_WRITE, path, sizeof(path))); | ||
4513 | tagcache_build("/"); | 4458 | tagcache_build("/"); |
4514 | break; | 4459 | break; |
4515 | 4460 | ||
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) | |||
261 | 261 | ||
262 | bool check_rockboxdir(void) | 262 | bool check_rockboxdir(void) |
263 | { | 263 | { |
264 | char path[MAX_PATH]; | 264 | if(!dir_exists(ROCKBOX_DIR)) |
265 | if(!dir_exists(get_user_file_path(ROCKBOX_DIR, 0, path, sizeof(path)))) | ||
266 | { /* No need to localise this message. | 265 | { /* No need to localise this message. |
267 | If .rockbox is missing, it wouldn't work anyway */ | 266 | If .rockbox is missing, it wouldn't work anyway */ |
268 | int i; | 267 | int i; |