updated build system

This commit is contained in:
Scott E. Graves 2024-08-02 22:58:05 -05:00
parent 85b28f7ee3
commit cde0e92591

View File

@ -36,39 +36,15 @@ static const std::wstring directory_seperator_str_w{
}; };
[[nodiscard]] auto resolve(std::string path) -> std::string { [[nodiscard]] auto resolve(std::string path) -> std::string {
static constexpr const std::string_view function_name{ std::string home{};
static_cast<const char *>(__FUNCTION__), repertory::utils::use_getpwuid(getuid(), [&home](struct passwd *pw) {
}; home = (pw->pw_dir ? pw->pw_dir : "");
if (home.empty() || ((home == "/") && (getuid() != 0))) {
#if defined(HAS_WORDEXP_H) home = repertory::utils::path::combine("/home", {pw->pw_name});
try {
if (not path.empty()) {
wordexp_t wt{};
int ret{};
if ((ret = wordexp(path.c_str(), &wt, 0)) != 0) {
throw std::runtime_error("'wordexp()' failed|" + std::to_string(ret) +
'|' + path);
} }
});
path = wt.we_wordv[0U]; return repertory::utils::string::replace(path, "~", home);
wordfree(&wt);
}
} catch (const std::exception &e) {
repertory::utils::error::handle_exception(function_name, e);
} catch (...) {
repertory::utils::error::handle_exception(function_name);
}
#else // !defined(HAS_WORDEXP_H)
repertory::utils::string::replace(path, "~", "%USERPROFILE%");
std::string dest;
dest.resize(::ExpandEnvironmentStringsA(path.c_str(), nullptr, 0));
::ExpandEnvironmentStringsA(path.c_str(), dest.data(),
static_cast<DWORD>(dest.size()));
path = dest.c_str();
#endif // defined(HAS_WORDEXP_H)
return path;
} }
} // namespace } // namespace