@@ -393,7 +393,7 @@ void FileDialog::update_dir() {
393393}
394394
395395void FileDialog::_dir_submitted (String p_dir) {
396- String new_dir = p_dir;
396+ String new_dir = OS::get_singleton ()-> expand_path ( p_dir) ;
397397#ifdef WINDOWS_ENABLED
398398 if (root_prefix.is_empty () && drives->is_visible () && !new_dir.is_network_share_path () && new_dir.is_absolute_path () && new_dir.find (" :/" ) == -1 && new_dir.find (" :\\ " ) == -1 ) {
399399 // Non network path without X:/ prefix on Windows, add drive letter.
@@ -466,6 +466,9 @@ void FileDialog::_action_pressed() {
466466 }
467467
468468 String file_text = filename_edit->get_text ();
469+
470+ file_text = OS::get_singleton ()->expand_path (file_text);
471+
469472 String f = file_text.is_absolute_path () ? file_text : dir_access->get_current_dir ().path_join (file_text);
470473
471474 if ((mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_FILE) && (dir_access->file_exists (f) || dir_access->is_bundle (f))) {
@@ -1203,7 +1206,7 @@ String FileDialog::get_current_path() const {
12031206}
12041207
12051208void FileDialog::set_current_dir (const String &p_dir) {
1206- _change_dir (p_dir);
1209+ _change_dir (OS::get_singleton ()-> expand_path ( p_dir) );
12071210
12081211 _push_history ();
12091212}
@@ -1222,12 +1225,15 @@ void FileDialog::set_current_path(const String &p_path) {
12221225 if (!p_path.size ()) {
12231226 return ;
12241227 }
1225- int pos = MAX (p_path.rfind_char (' /' ), p_path.rfind_char (' \\ ' ));
1228+
1229+ String path = OS::get_singleton ()->expand_path (p_path);
1230+
1231+ int pos = MAX (path.rfind_char (' /' ), path.rfind_char (' \\ ' ));
12261232 if (pos == -1 ) {
1227- set_current_file (p_path );
1233+ set_current_file (path );
12281234 } else {
1229- String path_dir = p_path .substr (0 , pos);
1230- String path_file = p_path .substr (pos + 1 );
1235+ String path_dir = path .substr (0 , pos);
1236+ String path_file = path .substr (pos + 1 );
12311237 set_current_dir (path_dir);
12321238 set_current_file (path_file);
12331239 }
0 commit comments