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

Function ReadResource

engine/resource/src/resource_mounts.cpp:326–350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324}
325
326dmResource::Result ReadResource(HContext ctx, dmhash_t path_hash, const char* path, uint8_t* buffer, uint32_t buffer_size)
327{
328 DM_MUTEX_SCOPED_LOCK(ctx->m_Mutex);
329
330 uint32_t size = ctx->m_Mounts.Size();
331 for (uint32_t i = 0; i < size; ++i)
332 {
333 ArchiveMount& mount = ctx->m_Mounts[i];
334 dmResourceProvider::Result result = dmResourceProvider::ReadFile(mount.m_Archive, path_hash, path, buffer, buffer_size);
335 if (dmResourceProvider::RESULT_NOT_FOUND == result)
336 continue;
337 if (dmResourceProvider::RESULT_OK == result)
338 {
339 DM_RESOURCE_DBG_LOG(3, "%s: %s (%u bytes) - mount %s\n", __FUNCTION__, path, buffer_size, dmHashReverseSafe64(mount.m_NameHash));
340 DebugPrintMount(3, mount);
341 return dmResource::RESULT_OK;
342 }
343 return ProviderResultToResult(result);
344 }
345
346 if (!ctx->m_CustomFiles.Empty())
347 return ReadCustomResource(ctx, path_hash, buffer, buffer_size);
348
349 return dmResource::RESULT_RESOURCE_NOT_FOUND;
350}
351
352dmResource::Result ReadResourcePartial(HContext ctx, dmhash_t path_hash, const char* path, uint32_t offset, uint32_t size, uint8_t* buffer, uint32_t* nread)
353{

Callers 2

TEST_FFunction · 0.85

Calls 7

dmHashReverseSafe64Function · 0.85
DebugPrintMountFunction · 0.85
ProviderResultToResultFunction · 0.85
ReadCustomResourceFunction · 0.85
ReadFileFunction · 0.50
SizeMethod · 0.45
EmptyMethod · 0.45

Tested by 1

TEST_FFunction · 0.68