diff options
| author | RedworkDE <10944644+RedworkDE@users.noreply.github.com> | 2023-07-11 16:07:35 +0200 |
|---|---|---|
| committer | RedworkDE <10944644+RedworkDE@users.noreply.github.com> | 2023-07-26 16:18:31 +0200 |
| commit | aee1e50b48c6e42cb5b1aa1320772bc98098558d (patch) | |
| tree | 19c7375f3f1a122c608b2534c4c57f56fb557824 /core/config/project_settings.cpp | |
| parent | 202e4b2c1e7f8b25738b93d0e4d5066453d3edf3 (diff) | |
| download | redot-engine-aee1e50b48c6e42cb5b1aa1320772bc98098558d.tar.gz | |
Fix `ProjectSettings::localize_path` for Windows paths
Diffstat (limited to 'core/config/project_settings.cpp')
| -rw-r--r-- | core/config/project_settings.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 715ed61770..8bde75d364 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -146,30 +146,30 @@ const PackedStringArray ProjectSettings::_trim_to_supported_features(const Packe #endif // TOOLS_ENABLED String ProjectSettings::localize_path(const String &p_path) const { - if (resource_path.is_empty() || (p_path.is_absolute_path() && !p_path.begins_with(resource_path))) { - return p_path.simplify_path(); + String path = p_path.simplify_path(); + + if (resource_path.is_empty() || (path.is_absolute_path() && !path.begins_with(resource_path))) { + return path; } // Check if we have a special path (like res://) or a protocol identifier. - int p = p_path.find("://"); + int p = path.find("://"); bool found = false; if (p > 0) { found = true; for (int i = 0; i < p; i++) { - if (!is_ascii_alphanumeric_char(p_path[i])) { + if (!is_ascii_alphanumeric_char(path[i])) { found = false; break; } } } if (found) { - return p_path.simplify_path(); + return path; } Ref<DirAccess> dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - String path = p_path.replace("\\", "/").simplify_path(); - if (dir->change_dir(path) == OK) { String cwd = dir->get_current_dir(); cwd = cwd.replace("\\", "/"); @@ -187,7 +187,7 @@ String ProjectSettings::localize_path(const String &p_path) const { cwd = cwd.path_join(""); if (!cwd.begins_with(res_path)) { - return p_path; + return path; } return cwd.replace_first(res_path, "res://"); |
