diff options
author | William Wilgus <wilgus.william@gmail.com> | 2024-03-31 22:08:55 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2024-04-01 07:35:53 -0400 |
commit | 1dc22c7241e7a4560bc2ba5e920721df27c39778 (patch) | |
tree | 92005f1c98456b2db0cf78d30df9f0f648f75faf /apps | |
parent | 47784a777eca6cae3c4a6643f4bca5338373951f (diff) | |
download | rockbox-1dc22c7241e7a4560bc2ba5e920721df27c39778.tar.gz rockbox-1dc22c7241e7a4560bc2ba5e920721df27c39778.zip |
use path_append for setting directories is several settings
sprintf, strcpy, memccpy can all just go thru path_append
with the added benefit of some path sanitizing too
Change-Id: I33510b56a364b8b3a0b06f2ff14b76491f6e3870
Diffstat (limited to 'apps')
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 2 | ||||
-rw-r--r-- | apps/menus/recording_menu.c | 4 | ||||
-rw-r--r-- | apps/menus/settings_menu.c | 3 | ||||
-rw-r--r-- | apps/onplay.c | 14 | ||||
-rw-r--r-- | apps/playlist_catalog.c | 13 |
5 files changed, 18 insertions, 18 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 4d1526fcbc..9f6f61895a 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -305,7 +305,7 @@ static int get_image_id(int c) | |||
305 | void get_image_filename(const char *start, const char* bmpdir, | 305 | void get_image_filename(const char *start, const char* bmpdir, |
306 | char *buf, int buf_size) | 306 | char *buf, int buf_size) |
307 | { | 307 | { |
308 | snprintf(buf, buf_size, "%s/%s", bmpdir, start); | 308 | path_append(buf, bmpdir, start, buf_size); |
309 | } | 309 | } |
310 | 310 | ||
311 | static int parse_image_display(struct skin_element *element, | 311 | static int parse_image_display(struct skin_element *element, |
diff --git a/apps/menus/recording_menu.c b/apps/menus/recording_menu.c index d47a315d87..9ef0eb6bac 100644 --- a/apps/menus/recording_menu.c +++ b/apps/menus/recording_menu.c | |||
@@ -63,6 +63,7 @@ | |||
63 | #include "list.h" | 63 | #include "list.h" |
64 | #include "viewport.h" | 64 | #include "viewport.h" |
65 | #include "exported_menus.h" | 65 | #include "exported_menus.h" |
66 | #include "pathfuncs.h" | ||
66 | 67 | ||
67 | static bool no_source_in_menu = false; | 68 | static bool no_source_in_menu = false; |
68 | static int recmenu_callback(int action, | 69 | static int recmenu_callback(int action, |
@@ -305,7 +306,8 @@ MENUITEM_SETTING(rec_prerecord_time, &global_settings.rec_prerecord_time, NULL); | |||
305 | 306 | ||
306 | static int clear_rec_directory(void) | 307 | static int clear_rec_directory(void) |
307 | { | 308 | { |
308 | strcpy(global_settings.rec_directory, REC_BASE_DIR); | 309 | path_append(global_settings.rec_directory, REC_BASE_DIR, |
310 | PA_SEP_HARD, sizeof(global_settings.rec_directory)); | ||
309 | settings_save(); | 311 | settings_save(); |
310 | splash(HZ, ID2P(LANG_RESET_DONE_CLEAR)); | 312 | splash(HZ, ID2P(LANG_RESET_DONE_CLEAR)); |
311 | return false; | 313 | return false; |
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c index bfb69a9942..a71245cf80 100644 --- a/apps/menus/settings_menu.c +++ b/apps/menus/settings_menu.c | |||
@@ -193,7 +193,8 @@ MENUITEM_SETTING(browse_current, &global_settings.browse_current, NULL); | |||
193 | MENUITEM_SETTING(show_path_in_browser, &global_settings.show_path_in_browser, NULL); | 193 | MENUITEM_SETTING(show_path_in_browser, &global_settings.show_path_in_browser, NULL); |
194 | static int clear_start_directory(void) | 194 | static int clear_start_directory(void) |
195 | { | 195 | { |
196 | strcpy(global_settings.start_directory, "/"); | 196 | path_append(global_settings.start_directory, PATH_ROOTSTR, |
197 | PA_SEP_HARD, sizeof(global_settings.start_directory)); | ||
197 | settings_save(); | 198 | settings_save(); |
198 | splash(HZ, ID2P(LANG_RESET_DONE_CLEAR)); | 199 | splash(HZ, ID2P(LANG_RESET_DONE_CLEAR)); |
199 | return false; | 200 | return false; |
diff --git a/apps/onplay.c b/apps/onplay.c index ba06d13183..ccebee402e 100644 --- a/apps/onplay.c +++ b/apps/onplay.c | |||
@@ -1349,8 +1349,8 @@ MENUITEM_FUNCTION(add_to_faves_item, 0, ID2P(LANG_ADD_TO_FAVES), | |||
1349 | #if LCD_DEPTH > 1 | 1349 | #if LCD_DEPTH > 1 |
1350 | static bool set_backdrop(void) | 1350 | static bool set_backdrop(void) |
1351 | { | 1351 | { |
1352 | strmemccpy(global_settings.backdrop_file, selected_file, | 1352 | path_append(global_settings.backdrop_file, selected_file, |
1353 | sizeof(global_settings.backdrop_file)); | 1353 | PA_SEP_HARD, sizeof(global_settings.backdrop_file)); |
1354 | settings_save(); | 1354 | settings_save(); |
1355 | skin_backdrop_load_setting(); | 1355 | skin_backdrop_load_setting(); |
1356 | skin_backdrop_show(sb_get_backdrop(SCREEN_MAIN)); | 1356 | skin_backdrop_show(sb_get_backdrop(SCREEN_MAIN)); |
@@ -1362,8 +1362,8 @@ MENUITEM_FUNCTION(set_backdrop_item, 0, ID2P(LANG_SET_AS_BACKDROP), | |||
1362 | #ifdef HAVE_RECORDING | 1362 | #ifdef HAVE_RECORDING |
1363 | static bool set_recdir(void) | 1363 | static bool set_recdir(void) |
1364 | { | 1364 | { |
1365 | strmemccpy(global_settings.rec_directory, selected_file, | 1365 | path_append(global_settings.rec_directory, selected_file, |
1366 | sizeof(global_settings.rec_directory)); | 1366 | PA_SEP_HARD, sizeof(global_settings.rec_directory)); |
1367 | settings_save(); | 1367 | settings_save(); |
1368 | return false; | 1368 | return false; |
1369 | } | 1369 | } |
@@ -1372,9 +1372,9 @@ MENUITEM_FUNCTION(set_recdir_item, 0, ID2P(LANG_RECORDING_DIR), | |||
1372 | #endif | 1372 | #endif |
1373 | static bool set_startdir(void) | 1373 | static bool set_startdir(void) |
1374 | { | 1374 | { |
1375 | snprintf(global_settings.start_directory, | 1375 | path_append(global_settings.start_directory, selected_file, |
1376 | sizeof(global_settings.start_directory), | 1376 | PA_SEP_HARD, sizeof(global_settings.start_directory)); |
1377 | "%s/", selected_file); | 1377 | |
1378 | settings_save(); | 1378 | settings_save(); |
1379 | return false; | 1379 | return false; |
1380 | } | 1380 | } |
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c index bcca406494..69bcc54209 100644 --- a/apps/playlist_catalog.c +++ b/apps/playlist_catalog.c | |||
@@ -78,10 +78,7 @@ static size_t get_directory(char* dirbuf, size_t dirbuf_sz) | |||
78 | pl_dir = global_settings.playlist_catalog_dir; | 78 | pl_dir = global_settings.playlist_catalog_dir; |
79 | } | 79 | } |
80 | 80 | ||
81 | /* remove duplicate leading '/' */ | 81 | return path_append(dirbuf, pl_dir, PA_SEP_SOFT, dirbuf_sz); |
82 | path_strip_leading_separators(pl_dir, &pl_dir); | ||
83 | |||
84 | return strlcpy(dirbuf, pl_dir, dirbuf_sz); | ||
85 | } | 82 | } |
86 | 83 | ||
87 | /* Retrieve playlist directory from config file and verify it exists | 84 | /* Retrieve playlist directory from config file and verify it exists |
@@ -127,8 +124,8 @@ void catalog_set_directory(const char* directory) | |||
127 | } | 124 | } |
128 | else | 125 | else |
129 | { | 126 | { |
130 | strmemccpy(global_settings.playlist_catalog_dir, | 127 | path_append(global_settings.playlist_catalog_dir, directory, |
131 | directory, sizeof(global_settings.playlist_catalog_dir)); | 128 | PA_SEP_SOFT, sizeof(global_settings.playlist_catalog_dir)); |
132 | } | 129 | } |
133 | initialize_catalog(); | 130 | initialize_catalog(); |
134 | } | 131 | } |
@@ -204,8 +201,8 @@ restart: | |||
204 | { | 201 | { |
205 | if (strcmp(most_recent_playlist, selected_playlist)) /* isn't most recent one */ | 202 | if (strcmp(most_recent_playlist, selected_playlist)) /* isn't most recent one */ |
206 | { | 203 | { |
207 | strmemccpy(most_recent_playlist, selected_playlist, | 204 | path_append(most_recent_playlist, selected_playlist, |
208 | sizeof(most_recent_playlist)); | 205 | PA_SEP_SOFT, sizeof(most_recent_playlist)); |
209 | most_recent_selection = 0; | 206 | most_recent_selection = 0; |
210 | reopen_last_playlist = false; | 207 | reopen_last_playlist = false; |
211 | } | 208 | } |