Skip to content
Snippets Groups Projects
Commit e0a63605 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

[#1791] If XDG env variables are not null but empty, use default ones

parent fb6da2aa
Branches
Tags
No related merge requests found
...@@ -146,12 +146,22 @@ void HistoryManager::add_new_history_entry (HistoryItem *new_item) ...@@ -146,12 +146,22 @@ void HistoryManager::add_new_history_entry (HistoryItem *new_item)
int HistoryManager::create_history_path (std::string path) int HistoryManager::create_history_path (std::string path)
{ {
std::string filename, userdata; std::string filename, userdata, xdg_env, xdg_data;
xdg_data = std::string (HOMEDIR) + DIR_SEPARATOR_STR + ".local/share";
if (path == "") { if (path == "") {
// TODO Should use $XDG_DATA_HOME (which default to .local/share) instead of HOMEDIR // TODO Should use $XDG_DATA_HOME (which default to .local/share) instead of HOMEDIR
(XDG_DATA_HOME != NULL) ? userdata = std::string (XDG_DATA_HOME) : userdata = std::string (HOMEDIR) + DIR_SEPARATOR_STR + ".local/share"; if (XDG_DATA_HOME != NULL)
{
xdg_env = std::string (XDG_DATA_HOME);
(xdg_env.length() > 0) ? userdata = xdg_env
: userdata = xdg_data;
}
else
userdata = xdg_data;
filename = userdata + DIR_SEPARATOR_STR + PROGDIR; filename = userdata + DIR_SEPARATOR_STR + PROGDIR;
if (mkdir (filename.data(), 0755) != 0) { if (mkdir (filename.data(), 0755) != 0) {
......
...@@ -1291,10 +1291,21 @@ int ...@@ -1291,10 +1291,21 @@ int
ManagerImpl::createSettingsPath (void) ManagerImpl::createSettingsPath (void)
{ {
//_path = std::string (HOMEDIR) + DIR_SEPARATOR_STR + "." + PROGDIR; std::string xdg_config, xdg_env;
(XDG_CONFIG_HOME != NULL) ? _path = std::string (XDG_CONFIG_HOME)
: _path = std::string (HOMEDIR) + DIR_SEPARATOR_STR + ".config" + DIR_SEPARATOR_STR + PROGDIR; _debug ("XDG_CONFIG_HOME: %s\n", XDG_CONFIG_HOME);
xdg_config = std::string (HOMEDIR) + DIR_SEPARATOR_STR + ".config" + DIR_SEPARATOR_STR + PROGDIR;
//_path = std::string (HOMEDIR) + DIR_SEPARATOR_STR + "." + PROGDIR;
if (XDG_CONFIG_HOME != NULL)
{
xdg_env = std::string (XDG_CONFIG_HOME);
(xdg_env.length() > 0) ? _path = xdg_env
: _path = xdg_config;
}
else
_path = xdg_config;
if (mkdir (_path.data(), 0700) != 0) { if (mkdir (_path.data(), 0700) != 0) {
// If directory creation failed // If directory creation failed
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment