diff options
author | volzhs <volzhs@gmail.com> | 2018-01-01 02:10:03 +0900 |
---|---|---|
committer | volzhs <volzhs@gmail.com> | 2018-01-01 05:03:20 +0900 |
commit | 0341070cdeea615ac13b9524f18c4e2f5d0dff2d (patch) | |
tree | 77d2614fcd4e98b7e3e71dfda5c02585d831201e /editor | |
parent | 548bd4ef1d3528cd77dd8fb77be8de9a5d5d044f (diff) |
Fix duplicating file or folder
Fix #15206
Diffstat (limited to 'editor')
-rw-r--r-- | editor/filesystem_dock.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index dce5a10d67..b3999c63f8 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -819,7 +819,7 @@ void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const Strin DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); print_line("Duplicating " + old_path + " -> " + new_path); - Error err = da->copy(old_path, new_path); + Error err = p_item.is_file ? da->copy(old_path, new_path) : da->copy_dir(old_path, new_path); if (err == OK) { //Move/Rename any corresponding import settings too if (p_item.is_file && FileAccess::exists(old_path + ".import")) { @@ -980,10 +980,12 @@ void FileSystemDock::_duplicate_operation_confirm() { return; } - String old_path = to_duplicate.path.ends_with("/") ? to_duplicate.path.substr(0, to_duplicate.path.length() - 1) : to_rename.path; - String new_path = old_path.get_base_dir().plus_file(new_name); - if (old_path == new_path) { - return; + String new_path; + String base_dir = to_duplicate.path.get_base_dir(); + if (to_duplicate.is_file) { + new_path = base_dir.plus_file(new_name); + } else { + new_path = base_dir.substr(0, base_dir.find_last("/")) + "/" + new_name; } //Present a more user friendly warning for name conflict @@ -995,7 +997,7 @@ void FileSystemDock::_duplicate_operation_confirm() { } memdelete(da); - _try_duplicate_item(to_duplicate, new_name); + _try_duplicate_item(to_duplicate, new_path); //Rescan everything print_line("call rescan!"); |