mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Fix ProjectSettings::localize_path for Windows paths
This commit is contained in:
@@ -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://");
|
||||
|
||||
Reference in New Issue
Block a user