[env]: Make it more generic
This commit is contained in:
1 parent
ab537c2d8b
commit
976e17864a
19 files changed
+446
-77
No files matched your search
@@ -79,4 +79,17 @@ string get_local_appdata_path()
|
||||
std::unique_ptr<char, decltype(&free)> dirPtr(localAppDataDir, free);
|
||||
return localAppDataDirStr.empty() ? "" : localAppDataDirStr;
|
||||
}
|
||||
|
||||
string get_username()
|
||||
{
|
||||
char *localAppDataDir = nullptr;
|
||||
std::string localAppDataDirStr;
|
||||
errno_t err = _dupenv_s(&localAppDataDir, nullptr, "USERNAME");
|
||||
if (err == 0 && localAppDataDir != nullptr)
|
||||
{
|
||||
localAppDataDirStr = std::string(localAppDataDir);
|
||||
}
|
||||
std::unique_ptr<char, decltype(&free)> dirPtr(localAppDataDir, free);
|
||||
return localAppDataDirStr.empty() ? "" : localAppDataDirStr;
|
||||
}
|
||||
} // namespace CommonUtils
|
||||
Reference in new issue
Block a user