Fix ProjectSettings::localize_path for Windows paths

This commit is contained in:
RedworkDE 2023-07-30 22:25:39 +02:00
parent ac5d7dc821
commit 0c12e26ae1

View file

@ -64,15 +64,15 @@ String ProjectSettings::get_resource_path() const {
};
String ProjectSettings::localize_path(const String &p_path) const {
if (resource_path.empty() || p_path.begins_with("res://") || p_path.begins_with("user://") ||
(p_path.is_abs_path() && !p_path.begins_with(resource_path))) {
return p_path.simplify_path();
String path = p_path.simplify_path();
if (resource_path.empty() || path.begins_with("res://") || path.begins_with("user://") ||
(path.is_abs_path() && !path.begins_with(resource_path))) {
return path.simplify_path();
}
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("\\", "/");
@ -92,7 +92,7 @@ String ProjectSettings::localize_path(const String &p_path) const {
cwd = cwd.plus_file("");
if (!cwd.begins_with(res_path)) {
return p_path;
return path;
};
return cwd.replace_first(res_path, "res://");