diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-16 13:34:09 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-16 13:34:09 +0200 |
commit | 5b2eececfdf32508ca83539b5cb4b15d214750e2 (patch) | |
tree | c71eab30ac121ad8a318e37a61dba6964731b7e9 /editor/editor_file_system.cpp | |
parent | 8c6210a3ebdfe14cd60620a3cf202e53ed963bad (diff) | |
parent | c981e8b76554ba322aa36d756032d8d9131bc0bd (diff) | |
download | redot-engine-5b2eececfdf32508ca83539b5cb4b15d214750e2.tar.gz |
Merge pull request #93372 from KoBeWi/instant_folders,_like_instant_noodles,_but_for_storing_files
Don't rescan filesystem when adding new directory
Diffstat (limited to 'editor/editor_file_system.cpp')
-rw-r--r-- | editor/editor_file_system.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index b1b64b5d60..0cb50cee8f 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -3057,6 +3057,35 @@ void EditorFileSystem::move_group_file(const String &p_path, const String &p_new } } +void EditorFileSystem::add_new_directory(const String &p_path) { + String path = p_path.get_base_dir(); + EditorFileSystemDirectory *parent = filesystem; + int base = p_path.count("/"); + int max_bit = base + 1; + + while (path != "res://") { + EditorFileSystemDirectory *dir = get_filesystem_path(path); + if (dir) { + parent = dir; + break; + } + path = path.get_base_dir(); + base--; + } + + for (int i = base; i < max_bit; i++) { + EditorFileSystemDirectory *efd = memnew(EditorFileSystemDirectory); + efd->parent = parent; + efd->name = p_path.get_slice("/", i); + parent->subdirs.push_back(efd); + + if (i == base) { + parent->subdirs.sort_custom<DirectoryComparator>(); + } + parent = efd; + } +} + ResourceUID::ID EditorFileSystem::_resource_saver_get_resource_id_for_path(const String &p_path, bool p_generate) { if (!p_path.is_resource_file() || p_path.begins_with(ProjectSettings::get_singleton()->get_project_data_path())) { // Saved externally (configuration file) or internal file, do not assign an ID. |