summaryrefslogtreecommitdiff
path: root/editor/editor_export.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_export.cpp')
-rw-r--r--editor/editor_export.cpp61
1 files changed, 60 insertions, 1 deletions
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index 36fd86d88f..fe1dfa281c 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -37,7 +37,6 @@
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "io/zip_io.h"
-#include "os/dir_access.h"
#include "os/file_access.h"
#include "project_settings.h"
#include "script_language.h"
@@ -420,6 +419,63 @@ void EditorExportPlatform::_export_find_dependencies(const String &p_path, Set<S
}
}
+void EditorExportPlatform::_edit_files_with_filter(DirAccess *da, const Vector<String> &p_filters, Set<String> &r_list, bool exclude) {
+
+ da->list_dir_begin();
+ String cur_dir = da->get_current_dir().replace("\\", "/");
+ if (!cur_dir.ends_with("/"))
+ cur_dir += "/";
+
+ Vector<String> dirs;
+ String f;
+ while ((f = da->get_next()) != "") {
+ if (da->current_is_dir())
+ dirs.push_back(f);
+ else {
+ String fullpath = cur_dir + f;
+ for (int i = 0; i < p_filters.size(); ++i) {
+ if (fullpath.matchn(p_filters[i])) {
+ if (!exclude) {
+ r_list.insert(fullpath);
+ } else {
+ r_list.erase(fullpath);
+ }
+ }
+ }
+ }
+ }
+
+ da->list_dir_end();
+
+ for (int i = 0; i < dirs.size(); ++i) {
+ String dir = dirs[i];
+ if (dir.begins_with("."))
+ continue;
+ da->change_dir(dir);
+ _edit_files_with_filter(da, p_filters, r_list, exclude);
+ da->change_dir("..");
+ }
+}
+
+void EditorExportPlatform::_edit_filter_list(Set<String> &r_list, const String &p_filter, bool exclude) {
+
+ if (p_filter == "")
+ return;
+ Vector<String> split = p_filter.split(",");
+ Vector<String> filters;
+ for (int i = 0; i < split.size(); i++) {
+ String f = split[i].strip_edges();
+ if (f.empty())
+ continue;
+ filters.push_back(f);
+ }
+
+ DirAccess *da = DirAccess::open("res://");
+ ERR_FAIL_NULL(da);
+ _edit_files_with_filter(da, filters, r_list, exclude);
+ memdelete(da);
+}
+
Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata) {
Ref<EditorExportPlatform> platform = p_preset->get_platform();
@@ -449,6 +505,9 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
}
}
+ _edit_filter_list(paths, p_preset->get_include_filter(), false);
+ _edit_filter_list(paths, p_preset->get_exclude_filter(), true);
+
//store everything in the export medium
int idx = 0;
int total = paths.size();