diff options
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/slang-platform.cpp | 15 | ||||
| -rw-r--r-- | source/core/slang-platform.h | 3 |
2 files changed, 18 insertions, 0 deletions
diff --git a/source/core/slang-platform.cpp b/source/core/slang-platform.cpp index e735216f4..d02951e0b 100644 --- a/source/core/slang-platform.cpp +++ b/source/core/slang-platform.cpp @@ -1,4 +1,7 @@ // slang-platform.cpp + +#define _CRT_SECURE_NO_WARNINGS + #include "slang-platform.h" #include "slang-common.h" @@ -197,6 +200,18 @@ SLANG_COMPILE_TIME_ASSERT(E_OUTOFMEMORY == SLANG_E_OUT_OF_MEMORY); #endif // _WIN32 + +/* static */SlangResult PlatformUtil::getEnvironmentVariable(const UnownedStringSlice& name, StringBuilder& out) +{ + const char* value = getenv(String(name).getBuffer()); + if (value) + { + out.append(value); + return SLANG_OK; + } + return SLANG_E_NOT_FOUND; +} + /* static */PlatformKind PlatformUtil::getPlatformKind() { #if SLANG_WINRT diff --git a/source/core/slang-platform.h b/source/core/slang-platform.h index c3ad1c486..767e83c1d 100644 --- a/source/core/slang-platform.h +++ b/source/core/slang-platform.h @@ -128,6 +128,9 @@ namespace Slang /// True if the kind is part of the family static bool isFamily(PlatformFamily family, PlatformKind kind) { return (getPlatformFlags(family) & (PlatformFlags(1) << int(kind))) != 0; } + /// Given an environment name returns the set system variable. + /// Will return SLANG_E_NOT_FOUND if the variable is not set + static SlangResult getEnvironmentVariable(const UnownedStringSlice& name, StringBuilder& out); }; #ifndef _MSC_VER |
