| 3529 | } |
| 3530 | |
| 3531 | Error EditorFileSystem::make_dir_recursive(const String &p_path, const String &p_base_path) { |
| 3532 | Error err; |
| 3533 | Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES); |
| 3534 | if (!p_base_path.is_empty()) { |
| 3535 | err = da->change_dir(p_base_path); |
| 3536 | ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot open base directory '" + p_base_path + "'."); |
| 3537 | } |
| 3538 | |
| 3539 | if (da->dir_exists(p_path)) { |
| 3540 | return ERR_ALREADY_EXISTS; |
| 3541 | } |
| 3542 | |
| 3543 | err = da->make_dir_recursive(p_path); |
| 3544 | if (err != OK) { |
| 3545 | return err; |
| 3546 | } |
| 3547 | |
| 3548 | const String path = da->get_current_dir(); |
| 3549 | EditorFileSystemDirectory *parent = get_filesystem_path(path); |
| 3550 | ERR_FAIL_NULL_V(parent, ERR_FILE_NOT_FOUND); |
| 3551 | folders_to_sort.insert(parent->get_instance_id()); |
| 3552 | |
| 3553 | const PackedStringArray folders = p_path.trim_prefix(path).split("/", false); |
| 3554 | for (const String &folder : folders) { |
| 3555 | const int current = parent->find_dir_index(folder); |
| 3556 | if (current > -1) { |
| 3557 | parent = parent->get_subdir(current); |
| 3558 | continue; |
| 3559 | } |
| 3560 | |
| 3561 | EditorFileSystemDirectory *efd = memnew(EditorFileSystemDirectory); |
| 3562 | efd->parent = parent; |
| 3563 | efd->name = folder; |
| 3564 | parent->subdirs.push_back(efd); |
| 3565 | parent = efd; |
| 3566 | } |
| 3567 | |
| 3568 | _queue_refresh_filesystem(); |
| 3569 | return OK; |
| 3570 | } |
| 3571 | |
| 3572 | Error EditorFileSystem::copy_file(const String &p_from, const String &p_to) { |
| 3573 | _copy_file(p_from, p_to); |
no test coverage detected