From d9226e09495586279a06ec0e0af41e8ac6990970 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 22 Mar 2012 12:38:20 -0700 Subject: volk: fix for load prefs (config path) 1) add APPDATA to search path for windows 2) graceful fail and env vars not defined --- volk/lib/volk_prefs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/volk/lib/volk_prefs.c b/volk/lib/volk_prefs.c index b29d5fd87..7e705bed4 100644 --- a/volk/lib/volk_prefs.c +++ b/volk/lib/volk_prefs.c @@ -9,7 +9,14 @@ void get_config_path(char *path) { const char *suffix = "/.volk/volk_config"; - strcpy(path, getenv("HOME")); + char *home = NULL; + if (home == NULL) home = getenv("HOME"); + if (home == NULL) home = getenv("APPDATA"); + if (home == NULL){ + path = NULL; + return; + } + strcpy(path, home); strcat(path, suffix); } @@ -22,6 +29,7 @@ int load_preferences(struct volk_arch_pref **prefs) { //get the config path get_config_path(path); + if (path == NULL) return n_arch_prefs; //no prefs found config_file = fopen(path, "r"); if(!config_file) return n_arch_prefs; //no prefs found -- cgit