Skip to content

Commit 319bfa9

Browse files
committed
[Windows] Use the same API for all OS_Windows::*_environment functions.
1 parent 8120e03 commit 319bfa9

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

platform/windows/os_windows.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,16 +1614,7 @@ String OS_Windows::get_executable_path() const {
16141614
}
16151615

16161616
bool OS_Windows::has_environment(const String &p_var) const {
1617-
#ifdef MINGW_ENABLED
1618-
return _wgetenv((LPCWSTR)(p_var.utf16().get_data())) != nullptr;
1619-
#else
1620-
WCHAR *env;
1621-
size_t len;
1622-
_wdupenv_s(&env, &len, (LPCWSTR)(p_var.utf16().get_data()));
1623-
const bool has_env = env != nullptr;
1624-
free(env);
1625-
return has_env;
1626-
#endif
1617+
return GetEnvironmentVariableW((LPCWSTR)(p_var.utf16().get_data()), nullptr, 0) > 0;
16271618
}
16281619

16291620
String OS_Windows::get_environment(const String &p_var) const {

0 commit comments

Comments
 (0)