From 14e503137b2f68ae7d0f2ea6cf0931d6465c13ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Tue, 4 Oct 2016 20:38:20 -0700 Subject: [PATCH] Added getenv. --- include/bx/os.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/bx/os.h b/include/bx/os.h index 39505d7..2228e9c 100644 --- a/include/bx/os.h +++ b/include/bx/os.h @@ -222,6 +222,31 @@ namespace bx #endif // BX_PLATFORM_ } + inline bool getenv(const char* _name, char* _out, uint32_t* _inOutSize) + { +#if BX_PLATFORM_WINDOWS + DWORD len = ::GetEnvironmentVariableA(_name, _out, *_inOutSize); + bool result = len != 0 && len < *_inOutSize; + *_inOutSize = len; + return result; +#elif BX_PLATFORM_PS4 \ + || BX_PLATFORM_XBOXONE \ + || BX_PLATFORM_WINRT + BX_UNUSED(_name, _out, _inOutSize); + return false; +#else + const char* ptr = ::getenv(_name); + uint32_t len = 0; + if (NULL != ptr) + { + len = (uint32_t)strlen(ptr); + } + bool result = len != 0 && len < *_inOutSize; + *_inOutSize = len; + return result; +#endif // BX_PLATFORM_ + } + inline void setenv(const char* _name, const char* _value) { #if BX_PLATFORM_WINDOWS