| 123 | } |
| 124 | |
| 125 | uint16_t SectionStream::readMemoryBlock(char* data, int bufSize) |
| 126 | { |
| 127 | if(currentSectionIndex < 0) { |
| 128 | nextSection(); |
| 129 | } |
| 130 | |
| 131 | if(finished || currentSectionIndex < 0) { |
| 132 | return 0; |
| 133 | } |
| 134 | |
| 135 | auto sect = §ions[currentSectionIndex]; |
| 136 | if(sectionOffset >= sect->size) { |
| 137 | if(nextRecord()) { |
| 138 | ++sect->recordIndex; |
| 139 | ++sect->recordCount; |
| 140 | readOffset = stream->seekFrom(sect->start, SeekOrigin::Start); |
| 141 | sectionOffset = 0; |
| 142 | } else { |
| 143 | nextSection(); |
| 144 | if(finished) { |
| 145 | return 0; |
| 146 | } |
| 147 | sect = §ions[currentSectionIndex]; |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | bufSize = std::min(uint32_t(bufSize), sect->size - sectionOffset); |
| 152 | |
| 153 | return stream->readMemoryBlock(data, bufSize); |
| 154 | } |
| 155 | |
| 156 | int SectionStream::seekFrom(int offset, SeekOrigin origin) |
| 157 | { |
no test coverage detected