MCPcopy Create free account
hub / github.com/defold/defold / CheckAndGetResourceFromPath

Function CheckAndGetResourceFromPath

engine/resource/src/resource.cpp:807–828  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

805}
806
807static Result CheckAndGetResourceFromPath(HFactory factory, dmhash_t canonical_path_hash, void** resource_out)
808{
809 *resource_out = 0;
810
811 // Try to get from already loaded resources
812 ResourceDescriptor* rd = factory->m_Resources->Get(canonical_path_hash);
813 if (rd)
814 {
815 assert(factory->m_ResourceToHash->Get((uintptr_t) rd->m_Resource));
816 rd->m_ReferenceCount++;
817 *resource_out = rd->m_Resource;
818 return RESULT_OK;
819 }
820
821 if (factory->m_Resources->Full())
822 {
823 dmLogError("The max number of resources (%d) has been passed, tweak \"%s\" in the config file.", factory->m_Resources->Capacity(), MAX_RESOURCES_KEY);
824 return RESULT_OUT_OF_RESOURCES;
825 }
826
827 return RESULT_RESOURCE_NOT_FOUND;
828}
829
830static Result CheckAndGetResourceTypeFromPath(HFactory factory, const char* canonical_path, HResourceType* resource_type_out)
831{

Callers 2

CreateResourcePartialFunction · 0.85

Calls 4

assertFunction · 0.50
GetMethod · 0.45
FullMethod · 0.45
CapacityMethod · 0.45

Tested by

no test coverage detected