diff options
author | Josh Blum <josh@joshknows.com> | 2012-03-22 12:38:20 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2012-03-22 13:45:34 -0700 |
commit | d9226e09495586279a06ec0e0af41e8ac6990970 (patch) | |
tree | 31b262618d6d5ac8e32ae4bb1a52aec6c6c8f837 /volk | |
parent | d88328072d5ecd0c3c5aef05b705e2b4a1425d9f (diff) |
volk: fix for load prefs (config path)
1) add APPDATA to search path for windows
2) graceful fail and env vars not defined
Diffstat (limited to 'volk')
-rw-r--r-- | volk/lib/volk_prefs.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/volk/lib/volk_prefs.c b/volk/lib/volk_prefs.c index b29d5fd878..7e705bed46 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 |