From 70e48bf66dc76636743bfbee3e1b567d588db185 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Fri, 25 Feb 2011 14:31:26 +0000 Subject: [PATCH] RaaA: Create full config directory tree during initialization Also robustify against unset HOME environment var. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29397 a1c6a512-1295-4272-9138-f99709370657 --- firmware/common/rbpaths.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/firmware/common/rbpaths.c b/firmware/common/rbpaths.c index 8eebc1fe08..10fceb69d9 100644 --- a/firmware/common/rbpaths.c +++ b/firmware/common/rbpaths.c @@ -25,6 +25,7 @@ #include #include "rbpaths.h" #include "file.h" /* MAX_PATH */ +#include "logf.h" #include "gcc_extensions.h" #include "string-extra.h" #include "filefuncs.h" @@ -70,9 +71,19 @@ void paths_init(void) #if (CONFIG_PLATFORM & PLATFORM_ANDROID) mkdir("/sdcard/rockbox"); #else - char home_path[MAX_PATH]; - snprintf(home_path, sizeof(home_path), "%s/.config/rockbox.org", getenv("HOME")); - mkdir(home_path); + char config_dir[MAX_PATH]; + + const char *home = getenv("HOME"); + if (!home) + { + logf("HOME environment var not set. Can't write config"); + return; + } + + snprintf(config_dir, sizeof(config_dir), "%s/.config", home); + mkdir(config_dir); + snprintf(config_dir, sizeof(config_dir), "%s/.config/rockbox.org", home); + mkdir(config_dir); #endif }