Skip to content
Snippets Groups Projects
Commit 32a9e516 authored by jsiegle's avatar jsiegle
Browse files

Added getEnvironmentVariable from latest version of JUCE

parent b090e164
No related branches found
No related tags found
No related merge requests found
......@@ -557,6 +557,14 @@ const String juce_getOutputFromCommand (const String& command)
return result;
}
//=============================================================================
String SystemStats::getEnvironmentVariable (const String& name, const String& defaultValue)
{
if (const char* s = ::getenv (name.toUTF8()))
return String::fromUTF8 (s);
return defaultValue;
}
//==============================================================================
class InterProcessLock::Pimpl
......
......@@ -113,10 +113,10 @@ public:
{
if (e->getStringAttribute ("prefix") == "xdg")
{
String xdgDataHome = "~/.local/share";//(SystemStats::getEnvironmentVariable ("XDG_DATA_HOME", String::empty));
String xdgDataHome = (SystemStats::getEnvironmentVariable ("XDG_DATA_HOME", String::empty));
// if (xdgDataHome.trimStart().isEmpty())
// xdgDataHome = "~/.local/share";
if (xdgDataHome.trimStart().isEmpty())
xdgDataHome = "~/.local/share";
fontPath = File (xdgDataHome).getChildFile (fontPath).getFullPathName();
}
......
......@@ -357,5 +357,19 @@ const String SystemStats::getFullUserName()
return getLogonName();
}
String SystemStats::getEnvironmentVariable (const String& name, const String& defaultValue)
{
DWORD len = GetEnvironmentVariableW (name.toWideCharPointer(), 0, 0);
if (GetLastError() == ERROR_ENVVAR_NOT_FOUND)
return String (defaultValue);
HeapBlock<WCHAR> buffer (len);
len = GetEnvironmentVariableW (name.toWideCharPointer(), buffer, len);
return String (CharPointer_wchar_t (buffer),
CharPointer_wchar_t (buffer + len));
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment