String ResourceLoader::guess_full_filename(const String &p_path,const String& p_type) { String local_path = Globals::get_singleton()->localize_path(p_path); return find_complete_path(local_path,p_type); }
Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_path,const String& p_type_hint,bool p_no_cache,Error *r_error) { if (r_error) *r_error=ERR_CANT_OPEN; String local_path; if (p_path.is_rel_path()) local_path="res://"+p_path; else local_path = Globals::get_singleton()->localize_path(p_path); local_path=find_complete_path(local_path,p_type_hint); ERR_FAIL_COND_V(local_path=="",Ref<ResourceInteractiveLoader>()); if (!p_no_cache && ResourceCache::has(local_path)) { if (OS::get_singleton()->is_stdout_verbose()) print_line("load resource: "+local_path+" (cached)"); return RES( ResourceCache::get(local_path ) ); } if (OS::get_singleton()->is_stdout_verbose()) print_line("load resource: "); String remapped_path = PathRemap::get_singleton()->get_remap(local_path); String extension=remapped_path.extension(); bool found=false; for (int i=0;i<loader_count;i++) { if (!loader[i]->recognize(extension)) continue; if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) continue; found=true; Ref<ResourceInteractiveLoader> ril = loader[i]->load_interactive(remapped_path,r_error); if (ril.is_null()) continue; if (!p_no_cache) ril->set_local_path(local_path); return ril; } if (found) { ERR_EXPLAIN("Failed loading resource: "+p_path); } else { ERR_EXPLAIN("No loader found for resource: "+p_path); } ERR_FAIL_V(Ref<ResourceInteractiveLoader>()); return Ref<ResourceInteractiveLoader>(); }
RES ResourceLoader::load(const String &p_path,const String& p_type_hint,bool p_no_cache) { String local_path = Globals::get_singleton()->localize_path(p_path); local_path=find_complete_path(p_path,p_type_hint); ERR_FAIL_COND_V(local_path=="",RES()); if (!p_no_cache && ResourceCache::has(local_path)) { if (OS::get_singleton()->is_stdout_verbose()) print_line("load resource: "+local_path+" (cached)"); return RES( ResourceCache::get(local_path ) ); } String remapped_path = PathRemap::get_singleton()->get_remap(local_path); if (OS::get_singleton()->is_stdout_verbose()) print_line("load resource: "+remapped_path); String extension=remapped_path.extension(); bool found=false; for (int i=0;i<loader_count;i++) { if (!loader[i]->recognize(extension)) continue; if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) continue; found=true; RES res = loader[i]->load(remapped_path,local_path); if (res.is_null()) continue; if (!p_no_cache) res->set_path(local_path); #ifdef TOOLS_ENABLED res->set_edited(false); if (timestamp_on_load) { uint64_t mt = FileAccess::get_modified_time(remapped_path); //printf("mt %s: %lli\n",remapped_path.utf8().get_data(),mt); res->set_last_modified_time(mt); } #endif return res; } if (found) { ERR_EXPLAIN("Failed loading resource: "+p_path); } else { ERR_EXPLAIN("No loader found for resource: "+p_path); } ERR_FAIL_V(RES()); return RES(); }
String ResourceLoader::guess_full_filename(const String &p_path,const String& p_type) { String local_path; if (p_path.is_rel_path()) local_path="res://"+p_path; else local_path = Globals::get_singleton()->localize_path(p_path); return find_complete_path(local_path,p_type); }