| 1596 | } |
| 1597 | |
| 1598 | bool 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 | |
| 1633 | bool Content::isFileExist(String filename) { |
| 1634 | if (filename.empty()) { |
nothing calls this directly
no test coverage detected