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

Function LoadResourcePartial

engine/dlib/src/dlib/sys_android.cpp:454–481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

452 }
453
454 Result LoadResourcePartial(const char* path, uint32_t offset, uint32_t size, void* buffer, uint32_t* nread)
455 {
456 if (buffer == 0 || size == 0)
457 return RESULT_INVAL;
458
459 AAssetManager* am = GetAndroidAssetManager();
460 if (am)
461 {
462 const char* asset_path = FixAndroidResourcePath(path);
463
464 // NOTE: AASSET_MODE_BUFFER is much faster than AASSET_MODE_RANDOM.
465 AAsset* asset = AAssetManager_open(am, asset_path, AASSET_MODE_BUFFER);
466 if (asset)
467 {
468 int result = AAsset_seek(asset, offset, SEEK_SET);
469 if (result < 0)
470 {
471 return RESULT_INVAL;
472 }
473 uint32_t nmemb = (uint32_t)AAsset_read(asset, buffer, size);
474 AAsset_close(asset);
475 *nread = nmemb;
476 return RESULT_OK;
477 }
478 }
479
480 return dmSysPosix::LoadResourcePartial(path, offset, size, buffer, nread);
481 }
482
483 Result Rmdir(const char* path)
484 {

Callers

nothing calls this directly

Calls 2

FixAndroidResourcePathFunction · 0.85
GetAndroidAssetManagerFunction · 0.70

Tested by

no test coverage detected