mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-04-11 16:37:45 -04:00
validate global_settings.start_directory on startup
check for an ending slash and verify paths other than root exist Change-Id: I4e1b3d51d99e5f5b66bcc0d66866ae35a554f84d
This commit is contained in:
parent
246bf4af75
commit
9a6e3799e1
3 changed files with 25 additions and 1 deletions
|
|
@ -241,6 +241,7 @@ int main(void)
|
|||
#endif /* #ifdef AUTOROCK */
|
||||
|
||||
global_status.last_volume_change = 0;
|
||||
validate_start_directory_init();
|
||||
/* no calls INIT_ATTR functions after this point anymore!
|
||||
* see definition of INIT_ATTR in config.h */
|
||||
CHART(">root_menu");
|
||||
|
|
|
|||
23
apps/misc.c
23
apps/misc.c
|
|
@ -2018,4 +2018,27 @@ void clear_screen_buffer(bool update)
|
|||
}
|
||||
}
|
||||
|
||||
void validate_start_directory_init(void) /* INIT_ATTR */
|
||||
{
|
||||
char * const dirpath = global_settings.start_directory;
|
||||
char *slash = strrchr(dirpath, PATH_SEPCH);
|
||||
|
||||
if (!slash)
|
||||
{
|
||||
path_append(dirpath, PATH_ROOTSTR, PA_SEP_HARD,
|
||||
sizeof(global_settings.start_directory));
|
||||
return; /* if this doesn't exist we have bigger issues */
|
||||
}
|
||||
else if(slash[1] != '\0') /* ending slash required */
|
||||
{
|
||||
path_append(dirpath, dirpath, PA_SEP_HARD,
|
||||
sizeof(global_settings.start_directory));
|
||||
}
|
||||
if (slash != dirpath && !dir_exists(dirpath))
|
||||
{
|
||||
path_append(dirpath, PATH_ROOTSTR,
|
||||
PA_SEP_HARD, sizeof(global_settings.start_directory));
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* ndef __PCTOOL__ */
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame
|
|||
long default_event_handler(long event);
|
||||
bool list_stop_handler(void);
|
||||
void car_adapter_mode_init(void) INIT_ATTR;
|
||||
|
||||
void validate_start_directory_init(void) INIT_ATTR;
|
||||
/* Unicode byte order mark sequences and lengths */
|
||||
#define BOM_UTF_8 "\xef\xbb\xbf"
|
||||
#define BOM_UTF_8_SIZE 3
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue