Skip to content
Browse files

Added getEnvironmentVariable from latest version of JUCE

  • Loading branch information...
1 parent b090e16 commit 32a9e516cf315a25e9c9c44b2be500308e9673ea jsiegle committed Dec 15, 2012
View
8 JuceLibraryCode/src/native/common/juce_posix_SharedCode.h
@@ -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
View
6 JuceLibraryCode/src/native/linux/juce_linux_Fonts.cpp
@@ -113,10 +113,10 @@ class LinuxFontFileIterator
{
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();
}
View
14 JuceLibraryCode/src/native/windows/juce_win32_SystemStats.cpp
@@ -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 comments on commit 32a9e51

Please sign in to comment.
Something went wrong with that request. Please try again.