mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-16 20:15:38 +00:00
Added a FileSystemUtil function to return the system home directory
This commit is contained in:
parent
a95e161d12
commit
3472c6f852
|
@ -208,6 +208,31 @@ namespace Utils
|
|||
return homePath;
|
||||
}
|
||||
|
||||
std::string getSystemHomeDirectory()
|
||||
{
|
||||
#if defined(_WIN64)
|
||||
// On Windows we need to check HOMEDRIVE and HOMEPATH.
|
||||
std::wstring envHomeDrive;
|
||||
std::wstring envHomePath;
|
||||
#if defined(_MSC_VER) // MSVC compiler.
|
||||
wchar_t* buffer;
|
||||
if (!_wdupenv_s(&buffer, nullptr, L"HOMEDRIVE"))
|
||||
envHomeDrive = buffer;
|
||||
if (!_wdupenv_s(&buffer, nullptr, L"HOMEPATH"))
|
||||
envHomePath = buffer;
|
||||
#else
|
||||
envHomeDrive = _wgetenv(L"HOMEDRIVE");
|
||||
envHomePath = _wgetenv(L"HOMEPATH");
|
||||
#endif
|
||||
if (envHomeDrive.length() && envHomePath.length())
|
||||
return getGenericPath(Utils::String::wideStringToString(envHomeDrive) + "/" +
|
||||
Utils::String::wideStringToString(envHomePath));
|
||||
#else
|
||||
return getenv("HOME");
|
||||
#endif
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string getCWDPath()
|
||||
{
|
||||
// Return current working directory.
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace Utils
|
|||
StringList getPathList(const std::string& path);
|
||||
void setHomePath(const std::string& path);
|
||||
std::string getHomePath();
|
||||
std::string getSystemHomeDirectory();
|
||||
std::string getCWDPath();
|
||||
std::string getPathToBinary(const std::string& executable);
|
||||
void setExePath(const std::string& path);
|
||||
|
|
Loading…
Reference in a new issue