summaryrefslogtreecommitdiffstats
path: root/core/io/resource_importer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/io/resource_importer.cpp')
-rw-r--r--core/io/resource_importer.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp
index 4c16650439..b4c43abe00 100644
--- a/core/io/resource_importer.cpp
+++ b/core/io/resource_importer.cpp
@@ -118,9 +118,21 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy
}
#endif
- if (r_path_and_type.path.is_empty() || r_path_and_type.type.is_empty()) {
+ if (r_path_and_type.type.is_empty()) {
return ERR_FILE_CORRUPT;
}
+ if (r_path_and_type.path.is_empty()) {
+ // Some importers may not write files to the .godot folder, so the path can be empty.
+ if (r_path_and_type.importer.is_empty()) {
+ return ERR_FILE_CORRUPT;
+ }
+
+ // It's only invalid if the extension for the importer is not empty.
+ Ref<ResourceImporter> importer = get_importer_by_name(r_path_and_type.importer);
+ if (importer.is_null() || !importer->get_save_extension().is_empty()) {
+ return ERR_FILE_CORRUPT;
+ }
+ }
return OK;
}
@@ -352,6 +364,23 @@ ResourceUID::ID ResourceFormatImporter::get_resource_uid(const String &p_path) c
return pat.uid;
}
+Error ResourceFormatImporter::get_resource_import_info(const String &p_path, StringName &r_type, ResourceUID::ID &r_uid, String &r_import_group_file) const {
+ PathAndType pat;
+ Error err = _get_path_and_type(p_path, pat);
+
+ if (err == OK) {
+ r_type = pat.type;
+ r_uid = pat.uid;
+ r_import_group_file = pat.group_file;
+ } else {
+ r_type = "";
+ r_uid = ResourceUID::INVALID_ID;
+ r_import_group_file = "";
+ }
+
+ return err;
+}
+
Variant ResourceFormatImporter::get_resource_metadata(const String &p_path) const {
PathAndType pat;
Error err = _get_path_and_type(p_path, pat);