Skip to content

Commit 0654be5

Browse files
RenfengLiurpavlik
authored andcommitted
Enable read environment variable on Android
This fixs: #430
1 parent 650f751 commit 0654be5

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
@@ -327,14 +327,19 @@ static inline std::string PlatformUtilsGetSecureEnv(const char* name) {
327327

328328
#include <sys/system_properties.h>
329329

330-
static inline bool PlatformUtilsGetEnvSet(const char* /* name */) {
331-
// Stub func
332-
return false;
333-
}
330+
namespace detail {
334331

335-
static inline std::string PlatformUtilsGetEnv(const char* /* name */) {
336-
// Stub func
337-
return {};
332+
static inline char* ImplGetEnv(const char* name) { return getenv(name); }
333+
} // namespace detail
334+
335+
static inline bool PlatformUtilsGetEnvSet(const char* name) { return detail::ImplGetEnv(name) != nullptr; }
336+
337+
static inline std::string PlatformUtilsGetEnv(const char* name) {
338+
auto str = detail::ImplGetEnv(name);
339+
if (str == nullptr) {
340+
return {};
341+
}
342+
return str;
338343
}
339344

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

0 commit comments

Comments
 (0)