MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / make_dir_recursive

Method make_dir_recursive

editor/file_system/editor_file_system.cpp:3531–3570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3529}
3530
3531Error 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
3572Error EditorFileSystem::copy_file(const String &p_from, const String &p_to) {
3573 _copy_file(p_from, p_to);

Callers 15

ProjectManagerMethod · 0.45
_install_assetMethod · 0.45
_try_duplicate_itemMethod · 0.45
create_directoryMethod · 0.45
_on_confirmedMethod · 0.45
EditorPathsMethod · 0.45
_convert_to_frameworkMethod · 0.45
_copy_assetMethod · 0.45
runMethod · 0.45

Calls 12

splitMethod · 0.80
trim_prefixMethod · 0.80
find_dir_indexMethod · 0.80
get_subdirMethod · 0.80
createFunction · 0.50
is_emptyMethod · 0.45
change_dirMethod · 0.45
dir_existsMethod · 0.45
get_current_dirMethod · 0.45
insertMethod · 0.45
get_instance_idMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected