| 70 | } |
| 71 | |
| 72 | Vector<String> list_dir(const String &rel, bool is_main = false) { |
| 73 | Vector<String> ret; |
| 74 | Error err; |
| 75 | Ref<DirAccess> da = DirAccess::open(dir.path_join(rel), &err); |
| 76 | ERR_FAIL_COND_V_MSG(da.is_null(), ret, "Failed to open directory " + dir); |
| 77 | |
| 78 | if (da.is_null()) { |
| 79 | return ret; |
| 80 | } |
| 81 | Vector<String> dirs; |
| 82 | Vector<String> files; |
| 83 | |
| 84 | String base = absolute ? dir : ""; |
| 85 | da->set_include_hidden(include_hidden); |
| 86 | da->list_dir_begin(); |
| 87 | String f = da->get_next(); |
| 88 | while (!f.is_empty()) { |
| 89 | if (f == "." || f == "..") { |
| 90 | f = da->get_next(); |
| 91 | continue; |
| 92 | } else if (exclude_dot_prefix_and_gdignore && f[0] == '.') { |
| 93 | f = da->get_next(); |
| 94 | continue; |
| 95 | } else if (da->current_is_dir()) { |
| 96 | dirs.push_back(f); |
| 97 | } else { |
| 98 | if (exclude_dot_prefix_and_gdignore && f == ".gdignore") { |
| 99 | // ignore the entire directory |
| 100 | return {}; |
| 101 | } |
| 102 | files.push_back(f); |
| 103 | } |
| 104 | f = da->get_next(); |
| 105 | } |
| 106 | da->list_dir_end(); |
| 107 | |
| 108 | dirs.sort_custom<FileNoCaseComparator>(); |
| 109 | if (is_main) { |
| 110 | Vector<RecursiveListDirTaskData::Token> tokens; |
| 111 | for (auto &d : dirs) { |
| 112 | tokens.push_back(RecursiveListDirTaskData::Token{ rel.path_join(d), {} }); |
| 113 | } |
| 114 | |
| 115 | Ref<EditorProgressGDDC> ep; |
| 116 | TaskManager::TaskManagerID group_id = -1; |
| 117 | if (tokens.size() > 0) { |
| 118 | String desc = "Reading folder " + dir + " structure..."; |
| 119 | String task = "ListDirTaskData(" + dir + +")_" + String::num_int64(OS::get_singleton()->get_ticks_usec()); |
| 120 | if (show_progress) { |
| 121 | ep = EditorProgressGDDC::create(nullptr, task, desc, -1, true); |
| 122 | } |
| 123 | group_id = TaskManager::get_singleton()->add_group_task( |
| 124 | this, &RecursiveListDirTaskData::do_subdir_task, |
| 125 | tokens.ptrw(), tokens.size(), |
| 126 | &RecursiveListDirTaskData::get_step_description, |
| 127 | task, desc, |
| 128 | true, -1, true, ep, 0, show_progress); |
| 129 | } |
nothing calls this directly
no test coverage detected