MCPcopy Create free account
hub / github.com/Niko1221/Strata / read_section

Method read_section

engine/src/artifact/strata_reader.cpp:171–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169}
170
171bool StrataFileReader::read_section(uint32_t section_id, std::vector<uint8_t>& out, std::string& err) const {
172 if (section_id >= STRATA_NUM_SECTIONS) {
173 err = "Invalid section_id";
174 return false;
175 }
176 const auto& sec = hdr_.sections[section_id];
177 // a header whose lengths run past the file would ask for an allocation of that size: say so instead
178 if (file_size_ != 0 && (sec.file_offset > file_size_ || sec.byte_length > file_size_ - sec.file_offset) && sec.byte_length != 0) {
179 err = "Section " + std::to_string(section_id) + " extends past the end of the file (truncated file?)";
180 return false;
181 }
182 out.resize(static_cast<size_t>(sec.byte_length));
183 if (sec.byte_length == 0) return true;
184 return read_at(sec.file_offset, out.data(), out.size(), err);
185}
186
187bool StrataFileReader::read_expert_body(size_t dir_index, std::vector<uint8_t>& out, std::string& err) const {
188 if (dir_index >= experts_.size()) {

Callers 11

loadMethod · 0.45
read_section1Method · 0.45
selfcheckMethod · 0.45
selfcheckMethod · 0.45
load_vision_gpuMethod · 0.45
run_selfcheck_readerFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
test_v11_skippableFunction · 0.45
load_sec5Function · 0.45

Calls 5

to_stringFunction · 0.50
read_atFunction · 0.50
resizeMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by 4

mainFunction · 0.36
mainFunction · 0.36
test_v11_skippableFunction · 0.36
load_sec5Function · 0.36