MCPcopy Create free account
hub / github.com/alibaba/CicadaPlayer / Read

Method Read

framework/data_source/curl/curl_data_source2.cpp:445–490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

443}
444
445int CurlDataSource2::Read(void *buf, size_t size)
446{
447 int ret = 0;
448
449 if (rangeEnd != INT64_MIN || mFileSize > 0) {
450 /*
451 * avoid read after seek to end
452 */
453
454 int64_t end = mFileSize;
455 if (rangeEnd > 0) {
456 end = rangeEnd;
457 }
458 end = std::min(mFileSize, end);
459
460 if (end > 0) {
461 size = std::min(size, (size_t) (end - mPConnection->tell()));
462
463 if (size <= 0) {
464 return 0;
465 }
466 }
467 }
468
469 /* only request 1 byte, for truncated reads (only if not eof) */
470 if (mFileSize <= 0 || mPConnection->tell() < mFileSize) {
471 ret = mPConnection->FillBuffer(1, *mMulti, mNeedReconnect);
472 if (mNeedReconnect) {
473 closeConnections(false, true);
474 mPConnection->setReconnect(true);
475 int64_t seek = mPConnection->tell();
476 int64_t seekRet = Seek(seek, SEEK_SET);
477 assert(seekRet == seek);
478 }
479
480 if (ret < 0) {
481 AF_LOGE("CurlDataSource2::Read ret=%d", ret);
482 return ret;
483 }
484 }
485 ret = mPConnection->readBuffer(buf, size);
486 if (ret < 0) {
487 AF_LOGE("CurlDataSource2::Read ret=%d", ret);
488 }
489 return ret;
490}
491
492string CurlDataSource2::GetOption(const string &key)
493{

Callers

nothing calls this directly

Calls 6

minClass · 0.85
assertClass · 0.85
setReconnectMethod · 0.80
tellMethod · 0.45
FillBufferMethod · 0.45
readBufferMethod · 0.45

Tested by

no test coverage detected