summaryrefslogtreecommitdiff
path: root/core/bind
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2018-08-10 15:57:43 -0300
committerJuan Linietsky <reduzio@gmail.com>2018-08-10 15:57:43 -0300
commit852378109fa701101c851c789cc5306298d2a636 (patch)
tree7fd2fa87c5d954a8370aac88a458918d248f931f /core/bind
parent767fb2fa0ba14ee6afb4eeeaad12e5dee944547b (diff)
Added function ResourceLoader.exists(), to check if a resource exists. Closes #19140
Diffstat (limited to 'core/bind')
-rw-r--r--core/bind/core_bind.cpp11
-rw-r--r--core/bind/core_bind.h3
2 files changed, 10 insertions, 4 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index af1d49ae8c..04e6f51b0d 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -112,11 +112,15 @@ PoolStringArray _ResourceLoader::get_dependencies(const String &p_path) {
return ret;
};
-bool _ResourceLoader::has(const String &p_path) {
+bool _ResourceLoader::has_cached(const String &p_path) {
String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
return ResourceCache::has(local_path);
-};
+}
+
+bool _ResourceLoader::exists(const String &p_path, const String &p_type_hint) {
+ return ResourceLoader::exists(p_path, p_type_hint);
+}
void _ResourceLoader::_bind_methods() {
@@ -125,7 +129,8 @@ void _ResourceLoader::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_recognized_extensions_for_type", "type"), &_ResourceLoader::get_recognized_extensions_for_type);
ClassDB::bind_method(D_METHOD("set_abort_on_missing_resources", "abort"), &_ResourceLoader::set_abort_on_missing_resources);
ClassDB::bind_method(D_METHOD("get_dependencies", "path"), &_ResourceLoader::get_dependencies);
- ClassDB::bind_method(D_METHOD("has", "path"), &_ResourceLoader::has);
+ ClassDB::bind_method(D_METHOD("has_cached", "path"), &_ResourceLoader::has_cached);
+ ClassDB::bind_method(D_METHOD("exists", "path", "type_hint"), &_ResourceLoader::exists, DEFVAL(""));
}
_ResourceLoader::_ResourceLoader() {
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 1729c23779..8327149f49 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -55,7 +55,8 @@ public:
PoolVector<String> get_recognized_extensions_for_type(const String &p_type);
void set_abort_on_missing_resources(bool p_abort);
PoolStringArray get_dependencies(const String &p_path);
- bool has(const String &p_path);
+ bool has_cached(const String &p_path);
+ bool exists(const String &p_path, const String &p_type_hint = "");
_ResourceLoader();
};