| 14 | namespace |
| 15 | { |
| 16 | std::filesystem::path getUserHome() |
| 17 | { |
| 18 | const char* dir = getenv("HOME"); |
| 19 | if (dir == nullptr) |
| 20 | { |
| 21 | struct passwd* pwd = getpwuid(getuid()); |
| 22 | if (pwd != nullptr) |
| 23 | { |
| 24 | dir = pwd->pw_dir; |
| 25 | } |
| 26 | } |
| 27 | if (dir == nullptr) |
| 28 | return {}; |
| 29 | else |
| 30 | return dir; |
| 31 | } |
| 32 | |
| 33 | std::filesystem::path getEnv(const std::string& envVariable, const std::filesystem::path& fallback) |
| 34 | { |
no outgoing calls
no test coverage detected