Skip to content
Permalink
Browse files

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>
  • Loading branch information
rkitover committed Sep 12, 2019
1 parent 32fbfec commit 0f2c8cab082451e5f6388db08cbb3e3eb85aad62
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/Util.cpp
@@ -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");

0 comments on commit 0f2c8ca

Please sign in to comment.
You can’t perform that action at this time.