You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-20 14:45:44 +00:00
Fix unexpected behaviors of using Duplicate To on folders
Fix folder not being copied when empty. Fix Keep Both would generate wrong paths when copying folders.
This commit is contained in:
@@ -1528,6 +1528,8 @@ void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const Strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
da->make_dir(new_path);
|
||||||
|
|
||||||
// Recursively duplicate all files inside the folder.
|
// Recursively duplicate all files inside the folder.
|
||||||
Ref<DirAccess> old_dir = DirAccess::open(old_path);
|
Ref<DirAccess> old_dir = DirAccess::open(old_path);
|
||||||
ERR_FAIL_COND(old_dir.is_null());
|
ERR_FAIL_COND(old_dir.is_null());
|
||||||
@@ -1894,22 +1896,15 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool p_cop
|
|||||||
if (p_overwrite == OVERWRITE_RENAME) {
|
if (p_overwrite == OVERWRITE_RENAME) {
|
||||||
new_paths.write[i] = _get_unique_name(to_move[i], p_to_path);
|
new_paths.write[i] = _get_unique_name(to_move[i], p_to_path);
|
||||||
} else {
|
} else {
|
||||||
new_paths.write[i] = p_to_path.path_join(to_move[i].path.get_file());
|
new_paths.write[i] = p_to_path.path_join(to_move[i].path.trim_suffix("/").get_file());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_copy) {
|
if (p_copy) {
|
||||||
bool is_copied = false;
|
bool is_copied = false;
|
||||||
for (int i = 0; i < to_move.size(); i++) {
|
for (int i = 0; i < to_move.size(); i++) {
|
||||||
String old_path = to_move[i].path;
|
if (to_move[i].path != new_paths[i]) {
|
||||||
String new_path = new_paths[i];
|
_try_duplicate_item(to_move[i], new_paths[i]);
|
||||||
|
|
||||||
if (!to_move[i].is_file) {
|
|
||||||
new_path = new_path.path_join(old_path.trim_suffix("/").get_file());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (old_path != new_path) {
|
|
||||||
_try_duplicate_item(to_move[i], new_path);
|
|
||||||
is_copied = true;
|
is_copied = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1934,15 +1929,8 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool p_cop
|
|||||||
HashMap<String, String> folder_renames;
|
HashMap<String, String> folder_renames;
|
||||||
|
|
||||||
for (int i = 0; i < to_move.size(); i++) {
|
for (int i = 0; i < to_move.size(); i++) {
|
||||||
String old_path = to_move[i].path;
|
if (to_move[i].path != new_paths[i]) {
|
||||||
String new_path = new_paths[i];
|
_try_move_item(to_move[i], new_paths[i], file_renames, folder_renames);
|
||||||
|
|
||||||
if (!to_move[i].is_file) {
|
|
||||||
new_path = new_path.path_join(old_path.trim_suffix("/").get_file());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (old_path != new_path) {
|
|
||||||
_try_move_item(to_move[i], new_path, file_renames, folder_renames);
|
|
||||||
is_moved = true;
|
is_moved = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user