Skip to content

Commit

Permalink
Fix disambiguate_filenames absolute paths on Unix
Browse files Browse the repository at this point in the history
Also clean up relative path handling to use get_basename()
  • Loading branch information
RedMser committed Nov 6, 2022
1 parent 9580769 commit f174326
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("/");
Expand All @@ -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];
}
}
Expand Down Expand Up @@ -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("/");
Expand Down

0 comments on commit f174326

Please sign in to comment.