MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / loadByChunks

Method loadByChunks

Source/Basic/Content.cpp:1598–1631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1596}
1597
1598bool Content::loadByChunks(String filename, const std::function<bool(uint8_t*, int)>& handler) {
1599 if (filename.empty()) {
1600 return false;
1601 }
1602 auto fullPathAndPackage = getFullPathAndPackage(filename);
1603 if (fullPathAndPackage.zipFile) {
1604 return fullPathAndPackage.zipFile->getFileDataByChunks(fullPathAndPackage.zipRelativePath, handler);
1605 }
1606 std::string fullPath = fullPathAndPackage.fullPath;
1607 if (isAndroidAsset(fullPath)) {
1608 if (_apkFile->getFileDataByChunks(getAndroidAssetName(fullPath), handler)) {
1609 return true;
1610 }
1611 } else {
1612 BLOCK_START {
1613 FILE* file = fopen(fullPath.c_str(), "rb");
1614 BREAK_IF(!file);
1615 uint8_t buffer[DORA_COPY_BUFFER_SIZE];
1616 int size = 0;
1617 do {
1618 size = s_cast<int>(fread(buffer, sizeof(uint8_t), DORA_COPY_BUFFER_SIZE, file));
1619 if (size > 0) {
1620 if (handler(buffer, size)) {
1621 return false;
1622 }
1623 }
1624 } while (size > 0);
1625 fclose(file);
1626 return true;
1627 }
1628 BLOCK_END
1629 }
1630 return false;
1631}
1632
1633bool Content::isFileExist(String filename) {
1634 if (filename.empty()) {

Callers

nothing calls this directly

Calls 12

fopenFunction · 0.85
freadFunction · 0.85
handlerFunction · 0.85
fcloseFunction · 0.85
SDL_RWFromFileFunction · 0.85
SDL_RWcloseFunction · 0.85
SDL_RWreadFunction · 0.85
getFileDataByChunksMethod · 0.80
toStringMethod · 0.65
ErrorEnum · 0.50
emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected