comparison main.c @ 691:b5d5d37bbc64

Use th_get_home_dir().
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 25 Dec 2019 15:18:47 +0200
parents 6fa9c36d0634
children 863542691130
comparison
equal deleted inserted replaced
690:6fa9c36d0634 691:b5d5d37bbc64
2029 2029
2030 th_cfg_add_section(&cfg, "logging", tmpcfg); 2030 th_cfg_add_section(&cfg, "logging", tmpcfg);
2031 2031
2032 // Get home directory path 2032 // Get home directory path
2033 { 2033 {
2034 setHomeDir = th_get_home_dir();
2035
2034 #if defined(TH_PLAT_WINDOWS) 2036 #if defined(TH_PLAT_WINDOWS)
2035 char tmpPath[MAX_PATH];
2036 if (SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, tmpPath) == S_OK)
2037 setHomeDir = th_strdup(tmpPath);
2038
2039 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); 2037 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
2040 setConfigDir = th_strdup(setHomeDir); 2038 setConfigDir = th_strdup(setHomeDir);
2041 #elif defined(USE_XDG) 2039 #elif defined(USE_XDG)
2042 const char *xdgConfigDir = getenv("XDG_CONFIG_HOME"); 2040 const char *xdgConfigDir = getenv("XDG_CONFIG_HOME");
2043 setHomeDir = th_strdup(getenv("HOME"));
2044 2041
2045 // If XDG is enabled, try the environment variable first 2042 // If XDG is enabled, try the environment variable first
2046 if (xdgConfigDir != NULL && strcmp(xdgConfigDir, "")) 2043 if (xdgConfigDir != NULL && strcmp(xdgConfigDir, ""))
2047 setConfigDir = th_strdup_printf("%s/%s/", xdgConfigDir, SET_XDG_CONFIG_DIR); 2044 setConfigDir = th_strdup_printf("%s/%s/", xdgConfigDir, SET_XDG_CONFIG_DIR);
2048 else 2045 else
2049 // Nope, try the obvious alternative 2046 // Nope, try the obvious alternative
2050 setConfigDir = th_strdup_printf("%s/.config/%s/", setHomeDir, SET_XDG_CONFIG_DIR); 2047 setConfigDir = th_strdup_printf("%s/.config/%s/", setHomeDir, SET_XDG_CONFIG_DIR);
2051 #else 2048 #else
2052 setHomeDir = th_strdup(getenv("HOME"));
2053 setConfigDir = th_strdup(setHomeDir); 2049 setConfigDir = th_strdup(setHomeDir);
2054 #endif 2050 #endif
2055 } 2051 }
2056 2052
2057 if (setConfigDir != NULL) 2053 if (setConfigDir != NULL)