common : delete common_get_path_from_env() (#31444)
Signed-off-by: Adrien Gallouët <angt@huggingface.co>
This commit is contained in:
1 parent
cd959bae99
commit
52e53a76df
5 files changed
+11
-28
No files matched your search
@@ -128,13 +128,10 @@ static std::string path_to_utf8(const fs::path & p) {
|
||||
static const std::string & home_dir() {
|
||||
static const std::string home = [] {
|
||||
#ifdef _WIN32
|
||||
// the narrow getenv would return the profile path in the active code page
|
||||
const wchar_t * w = _wgetenv(L"HOME");
|
||||
if (w == nullptr) w = _wgetenv(L"USERPROFILE");
|
||||
return w ? path_to_utf8(fs::path(w)) : std::string();
|
||||
const std::string h = common_get_env("HOME");
|
||||
return h.empty() ? common_get_env("USERPROFILE") : h;
|
||||
#else
|
||||
const char * h = getenv("HOME");
|
||||
return h ? std::string(h) : std::string();
|
||||
return common_get_env("HOME");
|
||||
#endif
|
||||
}();
|
||||
return home;
|
||||
|
||||
Reference in new issue
Block a user