updated build system
This commit is contained in:
parent
29af6e5b7c
commit
30806c6ebd
36
support/3rd_party/src/utils/path.cpp
vendored
36
support/3rd_party/src/utils/path.cpp
vendored
@ -37,25 +37,31 @@ static const std::wstring directory_seperator_str_w{
|
|||||||
|
|
||||||
[[nodiscard]] auto resolve(std::string path) -> std::string {
|
[[nodiscard]] auto resolve(std::string path) -> std::string {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
repertory::utils::string::replace(path, "~", "%USERPROFILE%");
|
if (repertory::utils::string::contains(path, "~") ||
|
||||||
|
repertory::utils::string::contains(path, "%")) {
|
||||||
|
repertory::utils::string::replace(path, "~", "%USERPROFILE%");
|
||||||
|
|
||||||
std::string dest;
|
std::string dest;
|
||||||
dest.resize(::ExpandEnvironmentStringsA(path.c_str(), nullptr, 0));
|
dest.resize(::ExpandEnvironmentStringsA(path.c_str(), nullptr, 0));
|
||||||
::ExpandEnvironmentStringsA(path.c_str(), dest.data(),
|
::ExpandEnvironmentStringsA(path.c_str(), dest.data(),
|
||||||
static_cast<DWORD>(dest.size()));
|
static_cast<DWORD>(dest.size()));
|
||||||
path = dest.c_str();
|
path = dest.c_str();
|
||||||
return path;
|
}
|
||||||
#else // !defined (_WIN32)
|
#else // !defined (_WIN32)
|
||||||
std::string home{};
|
if (repertory::utils::string::contains(path, "~")) {
|
||||||
repertory::utils::use_getpwuid(getuid(), [&home](struct passwd *pw) {
|
std::string home{};
|
||||||
home = (pw->pw_dir ? pw->pw_dir : "");
|
repertory::utils::use_getpwuid(getuid(), [&home](struct passwd *pw) {
|
||||||
if (home.empty() || ((home == "/") && (getuid() != 0))) {
|
home = (pw->pw_dir ? pw->pw_dir : "");
|
||||||
home = repertory::utils::path::combine("/home", {pw->pw_name});
|
if (home.empty() || ((home == "/") && (getuid() != 0))) {
|
||||||
}
|
home = repertory::utils::path::combine("/home", {pw->pw_name});
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return repertory::utils::string::replace(path, "~", home);
|
return repertory::utils::string::replace(path, "~", home);
|
||||||
|
}
|
||||||
#endif // defined (_WIN32)
|
#endif // defined (_WIN32)
|
||||||
|
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user