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

Method getFileDataByChunks

Source/3rdParty/Zip/ZipUtils.cpp:255–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253}
254
255bool ZipFile::getFileDataByChunks(const std::string& fileName, const std::function<bool(unsigned char*, int)>& handler) {
256 BLOCK_START {
257 BREAK_IF(!_file);
258 BREAK_IF(fileName.empty());
259 auto archive = &_file->archive;
260 std::string searchName = getSearchName(fileName);
261 auto it = _file->fileList.find(searchName);
262 BREAK_IF(it == _file->fileList.end());
263 auto zipIter = mz_zip_reader_extract_file_iter_new(archive, it->second.name.c_str(), 0);
264 uint8_t buf[DORA_COPY_BUFFER_SIZE];
265 size_t nSize = 0, total = 0;
266 do {
267 nSize = mz_zip_reader_extract_iter_read(zipIter, buf, DORA_COPY_BUFFER_SIZE);
268 if (nSize > 0) {
269 if (handler(buf, nSize)) {
270 return false;
271 }
272 }
273 total += nSize;
274 } while (nSize != 0);
275 mz_zip_reader_extract_iter_free(zipIter);
276 if (total == 0 || total == (int)it->second.size) {
277 return true;
278 } else {
279 Error("ZipUtils: the file size is wrong: \"{}\".", fileName);
280 return false;
281 }
282 }
283 BLOCK_END
284 return false;
285}

Callers 3

unzipAsyncMethod · 0.80
getAttrMethod · 0.80
loadByChunksMethod · 0.80

Calls 10

getSearchNameFunction · 0.85
handlerFunction · 0.85
findMethod · 0.65
ErrorEnum · 0.50
emptyMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected