aboutsummaryrefslogtreecommitdiff
path: root/zencore/filesystem.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-02-13 13:02:06 +0000
committerGitHub <[email protected]>2023-02-13 05:02:06 -0800
commit1639507f8d3831322d7da5cfa0c63cd374695ddf (patch)
tree3760a70cdf9fdf749fc38db55ae754e21b050f95 /zencore/filesystem.cpp
parentno sentry report on port conflict (#228) (diff)
downloadzen-1639507f8d3831322d7da5cfa0c63cd374695ddf.tar.xz
zen-1639507f8d3831322d7da5cfa0c63cd374695ddf.zip
Move knowledge of UE env variable from zenserver to zen command line tool (#227)
* move knowledge of UE env variable from zenserver to zen command line tool * move env-fetching code to GetEnvVariable
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...