validate global_settings.start_directory on startup check for an ending slash and verify paths other than root exist
rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
| Newsgroups | gmane.comp.systems.archos.rockbox.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 9a6e3799e18ba1e365cb23f6a2a5044e49cecffc Author: William Wilgus <[email protected]> Date: Wed Feb 25 00:47:30 2026 -0500 validate global_settings.start_directory on startup check for an ending slash and verify paths other than root exist Change-Id: I4e1b3d51d99e5f5b66bcc0d66866ae35a554f84d diff --git a/apps/main.c b/apps/main.c index 009f2e96ac..510bcdfc34 100644 --- a/apps/main.c +++ b/apps/main.c @@ -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"); diff --git a/apps/misc.c b/apps/misc.c index 05f1fa6a93..b9a33d8665 100644 --- a/apps/misc.c +++ b/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__ */ diff --git a/apps/misc.h b/apps/misc.h index fd326c5a7d..c4aa718c4a 100644 --- a/apps/misc.h +++ b/apps/misc.h @@ -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 -- rockbox-cvs mailing list [email protected] https://lists.haxx.se/mailman/listinfo/rockbox-cvs