Fix ProjectSettings::localize_path
for Windows paths
This commit is contained in:
parent
ac5d7dc821
commit
0c12e26ae1
1 changed files with 6 additions and 6 deletions
|
@ -64,15 +64,15 @@ String ProjectSettings::get_resource_path() const {
|
||||||
};
|
};
|
||||||
|
|
||||||
String ProjectSettings::localize_path(const String &p_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://") ||
|
String path = p_path.simplify_path();
|
||||||
(p_path.is_abs_path() && !p_path.begins_with(resource_path))) {
|
|
||||||
return 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);
|
DirAccess *dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
|
|
||||||
String path = p_path.replace("\\", "/").simplify_path();
|
|
||||||
|
|
||||||
if (dir->change_dir(path) == OK) {
|
if (dir->change_dir(path) == OK) {
|
||||||
String cwd = dir->get_current_dir();
|
String cwd = dir->get_current_dir();
|
||||||
cwd = cwd.replace("\\", "/");
|
cwd = cwd.replace("\\", "/");
|
||||||
|
@ -92,7 +92,7 @@ String ProjectSettings::localize_path(const String &p_path) const {
|
||||||
cwd = cwd.plus_file("");
|
cwd = cwd.plus_file("");
|
||||||
|
|
||||||
if (!cwd.begins_with(res_path)) {
|
if (!cwd.begins_with(res_path)) {
|
||||||
return p_path;
|
return path;
|
||||||
};
|
};
|
||||||
|
|
||||||
return cwd.replace_first(res_path, "res://");
|
return cwd.replace_first(res_path, "res://");
|
||||||
|
|
Loading…
Reference in a new issue