diff options
author | RedMser <redmser.jj2@gmail.com> | 2022-11-06 15:51:45 +0100 |
---|---|---|
committer | RedMser <redmser.jj2@gmail.com> | 2022-11-06 16:34:59 +0100 |
commit | f1743263d3e4f110245f710846a6efec72fd27ef (patch) | |
tree | 4167dcab39237e15542329c8f50bb6dda8b31b7b /editor | |
parent | 9580769e9a8e9542e651859d61452a13cf1eb398 (diff) |
Fix disambiguate_filenames absolute paths on Unix
Also clean up relative path handling to use get_basename()
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_node.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 716e0b454f..a748572d2a 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -244,15 +244,11 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto String full_path = p_full_paths[set_idx]; // Get rid of file extensions and res:// prefixes. - if (scene_name.rfind(".") >= 0) { - scene_name = scene_name.substr(0, scene_name.rfind(".")); - } + scene_name = scene_name.get_basename(); if (full_path.begins_with("res://")) { full_path = full_path.substr(6); } - if (full_path.rfind(".") >= 0) { - full_path = full_path.substr(0, full_path.rfind(".")); - } + full_path = full_path.get_basename(); // Normalize trailing slashes when normalizing directory names. scene_name = scene_name.trim_suffix("/"); @@ -270,7 +266,7 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto String parent = full_path.substr(0, difference); int slash_idx = parent.rfind("/"); slash_idx = parent.rfind("/", slash_idx - 1); - parent = slash_idx >= 0 ? parent.substr(slash_idx + 1) : parent; + parent = (slash_idx >= 0 && parent.length() > 1) ? parent.substr(slash_idx + 1) : parent; r_filenames.write[set_idx] = parent + r_filenames[set_idx]; } } @@ -302,15 +298,11 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto String path = p_full_paths[E->get()]; // Get rid of file extensions and res:// prefixes. - if (scene_name.rfind(".") >= 0) { - scene_name = scene_name.substr(0, scene_name.rfind(".")); - } + scene_name = scene_name.get_basename(); if (path.begins_with("res://")) { path = path.substr(6); } - if (path.rfind(".") >= 0) { - path = path.substr(0, path.rfind(".")); - } + path = path.get_basename(); // Normalize trailing slashes when normalizing directory names. scene_name = scene_name.trim_suffix("/"); |