Skip to content

Commit 9078343

Browse files
committed
Enable read environment variable on Android
This fixs: KhronosGroup#430
1 parent 8270b15 commit 9078343

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/common/platform_utils.hpp

+12-7
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,20 @@ static inline bool PlatformUtilsSetEnv(const char* name, const char* value) {
347347
}
348348

349349
#elif defined(XR_OS_ANDROID)
350+
namespace detail {
350351

351-
static inline bool PlatformUtilsGetEnvSet(const char* /* name */) {
352-
// Stub func
353-
return false;
354-
}
352+
static inline char* ImplGetEnv(const char* name) { return getenv(name); }
355353

356-
static inline std::string PlatformUtilsGetEnv(const char* /* name */) {
357-
// Stub func
358-
return {};
354+
static inline int ImplSetEnv(const char* name, const char* value, int overwrite) { return setenv(name, value, overwrite); }
355+
} // namespace detail
356+
static inline bool PlatformUtilsGetEnvSet(const char* name) { return detail::ImplGetEnv(name) != nullptr; }
357+
358+
static inline std::string PlatformUtilsGetEnv(const char* name) {
359+
auto str = detail::ImplGetEnv(name);
360+
if (str == nullptr) {
361+
return {};
362+
}
363+
return str;
359364
}
360365

361366
static inline std::string PlatformUtilsGetSecureEnv(const char* /* name */) {

0 commit comments

Comments
 (0)