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

Function InsertResource

engine/resource/src/resource.cpp:1032–1055  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1030}
1031
1032Result InsertResource(HFactory factory, const char* path, uint64_t canonical_path_hash, ResourceDescriptor* descriptor)
1033{
1034 if (factory->m_Resources->Full())
1035 {
1036 dmLogError("The max number of resources (%d) has been passed, tweak \"%s\" in the config file.", factory->m_Resources->Capacity(), MAX_RESOURCES_KEY);
1037 return RESULT_OUT_OF_RESOURCES;
1038 }
1039
1040 assert(descriptor->m_Resource);
1041 assert(descriptor->m_ReferenceCount == 1);
1042
1043 factory->m_Resources->Put(canonical_path_hash, *descriptor);
1044 factory->m_ResourceToHash->Put((uintptr_t) descriptor->m_Resource, canonical_path_hash);
1045 if (factory->m_ResourceHashToFilename)
1046 {
1047 char canonical_path[RESOURCE_PATH_MAX];
1048 GetCanonicalPath(path, canonical_path, sizeof(canonical_path));
1049 factory->m_ResourceHashToFilename->Put(canonical_path_hash, strdup(canonical_path));
1050 }
1051
1052 descriptor->m_Version = IncreaseVersion(factory);
1053
1054 return RESULT_OK;
1055}
1056
1057Result GetRaw(HFactory factory, const char* name, void** resource, uint32_t* resource_size)
1058{

Callers 2

DoCreateResourceFunction · 0.85
CreateResourceFunction · 0.85

Calls 6

GetCanonicalPathFunction · 0.85
IncreaseVersionFunction · 0.85
assertFunction · 0.50
FullMethod · 0.45
CapacityMethod · 0.45
PutMethod · 0.45

Tested by

no test coverage detected