From be10817e1c09d5a41710435cf6d58deb6dde9301 Mon Sep 17 00:00:00 2001 From: Nick Peskett Date: Mon, 19 Mar 2012 09:56:38 +0000 Subject: Option to constrain get_next_dir() to directories below global_settings.start_directory. When enabled, if the user has set "Start File Browser Here" (config.cfg: start directory) to anything other than root and "Auto-Change Directory" is set to "Yes" or "Random", the directory returned when an auto change is required will be constrained to the value of "start directory" or below. Change-Id: Iaab773868c4cab5a54f6ae67bdb22e84642a9e4b Reviewed-on: http://gerrit.rockbox.org/182 Reviewed-by: Nick Peskett Tested-by: Nick Peskett --- apps/plugins/random_folder_advance_config.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'apps/plugins') diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c index f459aa0..7f6018d 100644 --- a/apps/plugins/random_folder_advance_config.c +++ b/apps/plugins/random_folder_advance_config.c @@ -65,8 +65,15 @@ static void traversedir(char* location, char* name) bool check = false; int i; - rb->snprintf(fullpath, sizeof(fullpath), "%s/%s", location, name); - dir = rb->opendir(fullpath); + /* behave differently if we're at root to avoid + duplication of the initial slash later on */ + if (location[0] == '\0' && name[0] == '\0') { + rb->strcpy(fullpath, ""); + dir = rb->opendir("/"); + } else { + rb->snprintf(fullpath, sizeof(fullpath), "%s/%s", location, name); + dir = rb->opendir(fullpath); + } if (dir) { entry = rb->readdir(dir); while (entry) { -- cgit v1.1