summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/os/os.h1
-rw-r--r--drivers/unix/os_unix.cpp5
-rw-r--r--drivers/unix/os_unix.h1
-rw-r--r--platform/uwp/os_uwp.cpp5
-rw-r--r--platform/uwp/os_uwp.h1
-rw-r--r--platform/windows/os_windows.cpp5
-rw-r--r--platform/windows/os_windows.h1
7 files changed, 19 insertions, 0 deletions
diff --git a/core/os/os.h b/core/os/os.h
index 36d4e5a8c1..9f3713e164 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -266,6 +266,7 @@ public:
virtual bool has_environment(const String &p_var) const = 0;
virtual String get_environment(const String &p_var) const = 0;
+ virtual bool set_environment(const String &p_var, const String &p_value) const = 0;
virtual String get_name() = 0;
virtual List<String> get_cmdline_args() const { return _cmdline; }
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index ce1c183242..39a8fbc153 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -469,6 +469,11 @@ String OS_Unix::get_environment(const String &p_var) const {
return "";
}
+bool OS_Unix::set_environment(const String &p_var, const String &p_value) const {
+
+ return setenv(p_var.utf8().get_data(), p_var.utf8().get_data(), /* overwrite: */ true) == 0;
+}
+
int OS_Unix::get_processor_count() const {
return sysconf(_SC_NPROCESSORS_CONF);
diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h
index 2a23da6f28..09ab4aa1d8 100644
--- a/drivers/unix/os_unix.h
+++ b/drivers/unix/os_unix.h
@@ -95,6 +95,7 @@ public:
virtual bool has_environment(const String &p_var) const;
virtual String get_environment(const String &p_var) const;
+ virtual bool set_environment(const String &p_var, const String &p_value) const;
virtual String get_locale() const;
virtual int get_processor_count() const;
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index ea0193b8ed..ea4f63b49c 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -739,6 +739,11 @@ String OSUWP::get_environment(const String &p_var) const {
return "";
};
+bool OSUWP::set_environment(const String &p_var, const String &p_value) const {
+
+ return false;
+}
+
String OSUWP::get_stdin_string(bool p_block) {
return String();
diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h
index 491c9bce03..5475c4e60a 100644
--- a/platform/uwp/os_uwp.h
+++ b/platform/uwp/os_uwp.h
@@ -213,6 +213,7 @@ public:
virtual bool has_environment(const String &p_var) const;
virtual String get_environment(const String &p_var) const;
+ virtual bool set_environment(const String &p_var, const String &p_value) const;
virtual void set_clipboard(const String &p_text);
virtual String get_clipboard() const;
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 35f9d541ef..9ae1be9afd 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -2604,6 +2604,11 @@ String OS_Windows::get_environment(const String &p_var) const {
return "";
}
+bool OS_Windows::set_environment(const String &p_var, const String &p_value) const {
+
+ return (bool)SetEnvironmentVariableW(p_var.c_str(), p_value.c_str());
+}
+
String OS_Windows::get_stdin_string(bool p_block) {
if (p_block) {
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 4936a69120..771789c86b 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -268,6 +268,7 @@ public:
virtual bool has_environment(const String &p_var) const;
virtual String get_environment(const String &p_var) const;
+ virtual bool set_environment(const String &p_var, const String &p_value) const;
virtual void set_clipboard(const String &p_text);
virtual String get_clipboard() const;