OS: Add unset_environment, better validate input
Instead of returning an undocumented boolean error code, we do the validation checks that should ensure a successful result. Based on: - https://linux.die.net/man/3/setenv - https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setenvironmentvariable
This commit is contained in:
parent
04a39ecd84
commit
818a9e99a4
8 changed files with 51 additions and 17 deletions
|
|
@ -322,8 +322,12 @@ String OS::get_environment(const String &p_var) const {
|
|||
return ::OS::get_singleton()->get_environment(p_var);
|
||||
}
|
||||
|
||||
bool OS::set_environment(const String &p_var, const String &p_value) const {
|
||||
return ::OS::get_singleton()->set_environment(p_var, p_value);
|
||||
void OS::set_environment(const String &p_var, const String &p_value) const {
|
||||
::OS::get_singleton()->set_environment(p_var, p_value);
|
||||
}
|
||||
|
||||
void OS::unset_environment(const String &p_var) const {
|
||||
::OS::get_singleton()->unset_environment(p_var);
|
||||
}
|
||||
|
||||
String OS::get_name() const {
|
||||
|
|
@ -548,9 +552,10 @@ void OS::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("is_process_running", "pid"), &OS::is_process_running);
|
||||
ClassDB::bind_method(D_METHOD("get_process_id"), &OS::get_process_id);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("has_environment", "variable"), &OS::has_environment);
|
||||
ClassDB::bind_method(D_METHOD("get_environment", "variable"), &OS::get_environment);
|
||||
ClassDB::bind_method(D_METHOD("set_environment", "variable", "value"), &OS::set_environment);
|
||||
ClassDB::bind_method(D_METHOD("has_environment", "variable"), &OS::has_environment);
|
||||
ClassDB::bind_method(D_METHOD("unset_environment", "variable"), &OS::unset_environment);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_name"), &OS::get_name);
|
||||
ClassDB::bind_method(D_METHOD("get_distribution_name"), &OS::get_distribution_name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue