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

Function ReadCustomResourcePartial

engine/resource/src/resource_mounts.cpp:273–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271}
272
273static dmResource::Result ReadCustomResourcePartial(HContext ctx, dmhash_t path_hash, uint32_t offset, uint32_t size, uint8_t* buffer, uint32_t* nread)
274{
275 // Lock should already be held
276 CustomFile* file = ctx->m_CustomFiles.Get(path_hash);
277 if (file)
278 {
279 if ((offset+size) > file->m_Size)
280 {
281 offset = dmMath::Min(offset, file->m_Size);
282 size = file->m_Size - offset;
283 }
284
285 memcpy(buffer, ((uint8_t*)file->m_Resource) + offset, size);
286 *nread = size;
287
288 DM_RESOURCE_DBG_LOG(3, "ReadResource OK: %s " DM_HASH_FMT " (offset: %u size: %u) (custom file)\n", dmHashReverseSafe64(path_hash), path_hash, offset, size);
289 return dmResource::RESULT_OK;
290 }
291 return dmResource::RESULT_RESOURCE_NOT_FOUND;
292}
293
294dmResource::Result GetResourceSize(HContext ctx, dmhash_t path_hash, const char* path, uint32_t* resource_size)
295{

Callers 1

ReadResourcePartialFunction · 0.85

Calls 3

MinFunction · 0.85
dmHashReverseSafe64Function · 0.85
GetMethod · 0.45

Tested by

no test coverage detected