Skip to content
This repository
Browse code

Added getEnvironmentVariable from latest version of JUCE

  • Loading branch information...
commit 32a9e516cf315a25e9c9c44b2be500308e9673ea 1 parent b090e16
Josh Siegle jsiegle authored
8 JuceLibraryCode/src/native/common/juce_posix_SharedCode.h
@@ -557,6 +557,14 @@ const String juce_getOutputFromCommand (const String& command)
557 557 return result;
558 558 }
559 559
  560 +//=============================================================================
  561 +String SystemStats::getEnvironmentVariable (const String& name, const String& defaultValue)
  562 +{
  563 + if (const char* s = ::getenv (name.toUTF8()))
  564 + return String::fromUTF8 (s);
  565 +
  566 + return defaultValue;
  567 +}
560 568
561 569 //==============================================================================
562 570 class InterProcessLock::Pimpl
6 JuceLibraryCode/src/native/linux/juce_linux_Fonts.cpp
@@ -113,10 +113,10 @@ class LinuxFontFileIterator
113 113 {
114 114 if (e->getStringAttribute ("prefix") == "xdg")
115 115 {
116   - String xdgDataHome = "~/.local/share";//(SystemStats::getEnvironmentVariable ("XDG_DATA_HOME", String::empty));
  116 + String xdgDataHome = (SystemStats::getEnvironmentVariable ("XDG_DATA_HOME", String::empty));
117 117
118   - // if (xdgDataHome.trimStart().isEmpty())
119   - // xdgDataHome = "~/.local/share";
  118 + if (xdgDataHome.trimStart().isEmpty())
  119 + xdgDataHome = "~/.local/share";
120 120
121 121 fontPath = File (xdgDataHome).getChildFile (fontPath).getFullPathName();
122 122 }
14 JuceLibraryCode/src/native/windows/juce_win32_SystemStats.cpp
@@ -357,5 +357,19 @@ const String SystemStats::getFullUserName()
357 357 return getLogonName();
358 358 }
359 359
  360 +String SystemStats::getEnvironmentVariable (const String& name, const String& defaultValue)
  361 +{
  362 + DWORD len = GetEnvironmentVariableW (name.toWideCharPointer(), 0, 0);
  363 + if (GetLastError() == ERROR_ENVVAR_NOT_FOUND)
  364 + return String (defaultValue);
  365 +
  366 + HeapBlock<WCHAR> buffer (len);
  367 + len = GetEnvironmentVariableW (name.toWideCharPointer(), buffer, len);
  368 +
  369 + return String (CharPointer_wchar_t (buffer),
  370 + CharPointer_wchar_t (buffer + len));
  371 +}
  372 +
  373 +
360 374
361 375 #endif

0 comments on commit 32a9e51

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