String ResourceLoader::find_complete_path(const String& p_path,const String& p_type) { //this is an old vestige when the engine saved files without extension. //remains here for compatibility with old projects and only because it //can be sometimes nice to open files using .* from a script and have it guess //the right extension. String local_path = p_path; if (local_path.ends_with("*")) { //find the extension for resource that ends with * local_path = local_path.substr(0,local_path.length()-1); List<String> extensions; get_recognized_extensions_for_type(p_type,&extensions); List<String> candidates; for(List<String>::Element *E=extensions.front();E;E=E->next()) { String path = local_path+E->get(); if (PathRemap::get_singleton()->has_remap(path) || FileAccess::exists(path)) { candidates.push_back(path); } } if (candidates.size()==0) { return ""; } else if (candidates.size()==1 || p_type=="") { return candidates.front()->get(); } else { for(List<String>::Element *E=candidates.front();E;E=E->next()) { String rt = get_resource_type(E->get()); if (ObjectTypeDB::is_type(rt,p_type)) { return E->get(); } } return ""; } } return local_path; }
bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_for_type) const { String extension = p_path.get_extension(); List<String> extensions; if (p_for_type == String()) { get_recognized_extensions(&extensions); } else { get_recognized_extensions_for_type(p_for_type, &extensions); } for (List<String>::Element *E = extensions.front(); E; E = E->next()) { if (E->get().nocasecmp_to(extension) == 0) return true; } return false; }