aboutsummaryrefslogtreecommitdiff
path: root/zencore
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
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')
-rw-r--r--zencore/filesystem.cpp23
-rw-r--r--zencore/include/zencore/filesystem.h2
2 files changed, 25 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...
diff --git a/zencore/include/zencore/filesystem.h b/zencore/include/zencore/filesystem.h
index f49135687..fa5f94170 100644
--- a/zencore/include/zencore/filesystem.h
+++ b/zencore/include/zencore/filesystem.h
@@ -181,6 +181,8 @@ struct DirectoryContent
void GetDirectoryContent(const std::filesystem::path& RootDir, uint8_t Flags, DirectoryContent& OutContent);
+std::string GetEnvVariable(std::string_view VariableName);
+
//////////////////////////////////////////////////////////////////////////
void filesystem_forcelink(); // internal