Skip to content

Commit

Permalink
Simplify to_real_path
Browse files Browse the repository at this point in the history
Signed-off-by: Tin Švagelj <[email protected]>
  • Loading branch information
Caellian committed Nov 15, 2024
1 parent a64f0af commit ec199aa
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,10 @@ double get_time() {
/// - `$HOME/a/b/../c/../../conky` -> `/home/conky_user/conky`
std::filesystem::path to_real_path(const std::filesystem::path &source) {
try {
std::string input;
std::string input = source.string();
if (source.string().compare(0, 1, "~") == 0) {
const char *home = std::getenv("HOME");
if (home) {
input = std::string(home) + source.string().substr(1);
} else {
input = source.string(); // Fallback if HOME is not set
}
} else {
input = source.string();
if (home) { input = std::string(home) + source.string().substr(1); }
}
std::string expanded = variable_substitute(input);
std::filesystem::path absolute = std::filesystem::absolute(expanded);
Expand Down

0 comments on commit ec199aa

Please sign in to comment.