Merge pull request #112844 from bruvzg/cwd_error

Add error message when trying to load project from CWD.
This commit is contained in:
Thaddeus Crews
2025-11-21 18:37:29 -06:00
7 changed files with 43 additions and 2 deletions

View File

@ -1678,6 +1678,14 @@ Error OS_Windows::set_cwd(const String &p_cwd) {
return OK;
}
String OS_Windows::get_cwd() const {
Char16String real_current_dir_name;
size_t str_len = GetCurrentDirectoryW(0, nullptr);
real_current_dir_name.resize_uninitialized(str_len + 1);
GetCurrentDirectoryW(real_current_dir_name.size(), (LPWSTR)real_current_dir_name.ptrw());
return String::utf16((const char16_t *)real_current_dir_name.get_data()).trim_prefix(R"(\\?\)").replace_char('\\', '/');
}
Vector<String> OS_Windows::get_system_fonts() const {
if (!dwrite_init) {
return Vector<String>();

View File

@ -201,6 +201,7 @@ public:
virtual double get_unix_time() const override;
virtual Error set_cwd(const String &p_cwd) override;
virtual String get_cwd() const override;
virtual void add_frame_delay(bool p_can_draw, bool p_wake_for_events) override;
virtual void delay_usec(uint32_t p_usec) const override;