aboutsummaryrefslogtreecommitdiff
path: root/zencore/filesystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zencore/filesystem.cpp')
-rw-r--r--zencore/filesystem.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp
index a2442a134..a17773024 100644
--- a/zencore/filesystem.cpp
+++ b/zencore/filesystem.cpp
@@ -1117,6 +1117,29 @@ GetDirectoryContent(const std::filesystem::path& RootDir, uint8_t Flags, Directo
Traversal.TraverseFileSystem(RootDir, Visit);
}
+std::string
+GetEnvVariable(std::string_view VariableName)
+{
+ ZEN_ASSERT(!VariableName.empty());
+#if ZEN_PLATFORM_WINDOWS
+
+ CHAR EnvVariableBuffer[1023 + 1];
+ DWORD RESULT = GetEnvironmentVariableA(std::string(VariableName).c_str(), EnvVariableBuffer, sizeof(EnvVariableBuffer));
+ if (RESULT > 0 && RESULT < sizeof(EnvVariableBuffer))
+ {
+ return std::string(EnvVariableBuffer);
+ }
+#endif
+#if ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC
+ char* EnvVariable = getenv(std::string(VariableName).c_str());
+ if (EnvVariable)
+ {
+ return std::string(EnvVariable);
+ }
+#endif
+ return "";
+}
+
//////////////////////////////////////////////////////////////////////////
//
// Testing related code follows...