diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2024-03-12 09:49:28 +0100 |
---|---|---|
committer | Sefa Eyeoglu <contact@scrumplex.net> | 2024-03-12 19:03:58 +0100 |
commit | f7c9ede286afa0a60b841a7d9fadf63d20c7059a (patch) | |
tree | 335b544fae2fe653a9a99799d992dca208b89ff5 /Settings.c | |
parent | f588b2731518e2a5b163d02cdeb3043c7d6fa92d (diff) |
Print message if config file was resolved
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
Diffstat (limited to 'Settings.c')
-rw-r--r-- | Settings.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -74,6 +74,7 @@ static void writeQuotedList(FILE* fd, char** list) { void Settings_delete(Settings* this) { free(this->filename); + free(this->initialFilename); for (unsigned int i = 0; i < HeaderLayout_getColumns(this->hLayout); i++) { String_freeArray(this->hColumns[i].names); free(this->hColumns[i].modes); @@ -795,7 +796,7 @@ Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicMeters, H char* legacyDotfile = NULL; const char* rcfile = getenv("HTOPRC"); if (rcfile) { - this->filename = xStrdup(rcfile); + this->initialFilename = xStrdup(rcfile); } else { const char* home = getenv("HOME"); if (!home) { @@ -806,11 +807,11 @@ Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicMeters, H char* configDir = NULL; char* htopDir = NULL; if (xdgConfigHome) { - this->filename = String_cat(xdgConfigHome, "/htop/htoprc"); + this->initialFilename = String_cat(xdgConfigHome, "/htop/htoprc"); configDir = xStrdup(xdgConfigHome); htopDir = String_cat(xdgConfigHome, "/htop"); } else { - this->filename = String_cat(home, "/.config/htop/htoprc"); + this->initialFilename = String_cat(home, "/.config/htop/htoprc"); configDir = String_cat(home, "/.config"); htopDir = String_cat(home, "/.config/htop"); } @@ -827,10 +828,9 @@ Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicMeters, H } } - char* resolvedFilename = xMalloc(PATH_MAX); - if (realpath(this->filename, resolvedFilename)) - free_and_xStrdup(&this->filename, resolvedFilename); - free(resolvedFilename); + this->filename = xMalloc(PATH_MAX); + if (!realpath(this->initialFilename, this->filename)) + free_and_xStrdup(&this->filename, this->initialFilename); this->colorScheme = 0; #ifdef HAVE_GETMOUSE |