This commit is contained in:
gabime
2019-12-08 17:08:20 +02:00
parent abbbda6f74
commit 0f24399887
7 changed files with 144 additions and 161 deletions

View File

@@ -536,18 +536,17 @@ SPDLOG_INLINE filename_t dir_name(filename_t path)
return pos != filename_t::npos ? path.substr(0, pos) : filename_t{};
}
std::string SPDLOG_INLINE getenv(const char* field)
std::string SPDLOG_INLINE getenv(const char *field)
{
#if defined(_MSC_VER) && !defined(__cplusplus_winrt)
size_t len = 0;
char buf[128];
bool ok = ::getenv_s(&len , buf, sizeof(buf), field) == 0;
bool ok = ::getenv_s(&len, buf, sizeof(buf), field) == 0;
return ok ? buf : std::string{};
#else // revert to getenv
char *buf = ::getenv(field);
return buf ? buf : std::string{};
#endif
}
} // namespace os