mirror of
https://github.com/godotengine/godot
synced 2024-09-16 03:36:52 +00:00
Use include/exclude export filters. Fixes #9860
This commit is contained in:
parent
9575dbdf78
commit
571a3a2dcd
|
@ -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();
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#ifndef EDITOR_EXPORT_H
|
||||
#define EDITOR_EXPORT_H
|
||||
|
||||
#include "os/dir_access.h"
|
||||
#include "resource.h"
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/main/timer.h"
|
||||
|
@ -157,6 +158,9 @@ private:
|
|||
static Error _save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total);
|
||||
static Error _save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total);
|
||||
|
||||
void _edit_files_with_filter(DirAccess *da, const Vector<String> &p_filters, Set<String> &r_list, bool exclude);
|
||||
void _edit_filter_list(Set<String> &r_list, const String &p_filter, bool exclude);
|
||||
|
||||
protected:
|
||||
bool exists_export_template(String template_file_name, String *err) const;
|
||||
String find_export_template(String template_file_name, String *err = NULL) const;
|
||||
|
|
Loading…
Reference in a new issue