MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / populateBlocks

Method populateBlocks

src/basicio.cpp:1064–1094  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1062}
1063
1064size_t RemoteIo::Impl::populateBlocks(size_t lowBlock, size_t highBlock) {
1065 // optimize: ignore all true blocks on left & right sides.
1066 while (!blocksMap_[lowBlock].isNone() && lowBlock < highBlock)
1067 lowBlock++;
1068 while (!blocksMap_[highBlock].isNone() && highBlock > lowBlock)
1069 highBlock--;
1070
1071 size_t rcount = 0;
1072 if (blocksMap_[highBlock].isNone()) {
1073 std::string data;
1074 getDataByRange(lowBlock, highBlock, data);
1075 rcount = data.length();
1076 if (rcount == 0) {
1077 throw Error(ErrorCode::kerErrorMessage, "Data By Range is empty. Please check the permission.");
1078 }
1079 auto source = reinterpret_cast<byte*>(const_cast<char*>(data.c_str()));
1080 size_t remain = rcount;
1081 size_t totalRead = 0;
1082 size_t iBlock = (rcount == size_) ? 0 : lowBlock;
1083
1084 while (remain) {
1085 auto allow = std::min<size_t>(remain, blockSize_);
1086 blocksMap_[iBlock].populate(&source[totalRead], allow);
1087 remain -= allow;
1088 totalRead += allow;
1089 iBlock++;
1090 }
1091 }
1092
1093 return rcount;
1094}
1095
1096RemoteIo::Impl::~Impl() {
1097 delete[] blocksMap_;

Callers 2

readMethod · 0.80
getbMethod · 0.80

Calls 4

ErrorFunction · 0.85
isNoneMethod · 0.80
c_strMethod · 0.80
populateMethod · 0.80

Tested by

no test coverage detected