1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Merge pull request #109276 from bruvzg/sym_copy

Fix symlink copy in `DirAccess::copy_dir`.
This commit is contained in:
Thaddeus Crews
2025-08-20 13:04:23 -05:00

View File

@@ -490,19 +490,22 @@ Error DirAccess::_copy_dir(Ref<DirAccess> &p_target_da, const String &p_to, int
while (!n.is_empty()) { while (!n.is_empty()) {
if (n != "." && n != "..") { if (n != "." && n != "..") {
if (p_copy_links && is_link(get_current_dir().path_join(n))) { if (p_copy_links && is_link(get_current_dir().path_join(n))) {
create_link(read_link(get_current_dir().path_join(n)), p_to + n); Error err = p_target_da->create_link(read_link(get_current_dir().path_join(n)), p_to + n);
if (err) {
ERR_PRINT(vformat("Failed to copy symlink \"%s\".", n));
}
} else if (current_is_dir()) { } else if (current_is_dir()) {
dirs.push_back(n); dirs.push_back(n);
} else { } else {
const String &rel_path = n; const String &rel_path = n;
if (!n.is_relative_path()) { if (!n.is_relative_path()) {
list_dir_end(); list_dir_end();
return ERR_BUG; ERR_FAIL_V_MSG(ERR_BUG, vformat("BUG: \"%s\" is not a relative path.", n));
} }
Error err = copy(get_current_dir().path_join(n), p_to + rel_path, p_chmod_flags); Error err = copy(get_current_dir().path_join(n), p_to + rel_path, p_chmod_flags);
if (err) { if (err) {
list_dir_end(); list_dir_end();
return err; ERR_FAIL_V_MSG(err, vformat("Failed to copy file \"%s\".", n));
} }
} }
} }