win: check APPDATA if LOCALAPPDATA is not found

Check for the APPDATA environment variable if there is no LOCALAPPDATA
environment variable for things like reading the config file.

Fix #407.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2019-09-12 03:01:16 +00:00
parent 32fbfec46c
commit 0f2c8cab08
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
1 changed files with 6 additions and 2 deletions

View File

@ -75,7 +75,9 @@ std::string get_xdg_user_config_home()
std::string home(getenv("HOME"));
path = home + "/Library/Application Support";
#elif _WIN32
std::string app_data(getenv("LOCALAPPDATA"));
char *app_data_env = getenv("LOCALAPPDATA");
if (!app_data_env) app_data_env = getenv("APPDATA");
std::string app_data(app_data_env);
path = app_data;
#else // Unix
char *xdg_var = getenv("XDG_CONFIG_HOME");
@ -103,7 +105,9 @@ std::string get_xdg_user_data_home()
std::string home(getenv("HOME"));
path = home + "/Library/Application Support";
#elif _WIN32
std::string app_data(getenv("LOCALAPPDATA"));
char *app_data_env = getenv("LOCALAPPDATA");
if (!app_data_env) app_data_env = getenv("APPDATA");
std::string app_data(app_data_env);
path = app_data;
#else // Unix
char *xdg_var = getenv("XDG_DATA_HOME");