MCPcopy Create free account
hub / github.com/LBANN/lbann / load_file

Function load_file

src/utils/file_utils.cpp:188–211  ·  view source on GitHub ↗

Load a file into a buffer

Source from the content-addressed store, hash-verified

186
187/// Load a file into a buffer
188bool load_file(const std::string filename, std::vector<char>& buf, bool append)
189{
190 std::ifstream file(filename, std::ios::binary);
191 if (!file.good()) {
192 LBANN_ERROR("!file.good() for filename: ", filename);
193 }
194
195 file.unsetf(std::ios::skipws);
196
197 file.seekg(0, std::ios::end);
198 const std::streamsize file_size = static_cast<std::streamsize>(file.tellg());
199
200 file.seekg(0, std::ios::beg);
201
202 if (!append) {
203 buf.clear();
204 }
205 const size_t cur_size = buf.size();
206 buf.resize(static_cast<size_t>(file_size) + cur_size);
207
208 file.read(buf.data() + cur_size, file_size);
209
210 return true;
211}
212
213namespace file {
214

Callers 10

process_imagesFunction · 0.85
image_listMethod · 0.85
load_fileMethod · 0.85
load_listMethod · 0.85
fetch_datumMethod · 0.85
fetch_responseMethod · 0.85
load_list_of_samplesMethod · 0.85
gen_list_of_samplesMethod · 0.85
load_list_of_samplesMethod · 0.85
load_list_of_samplesMethod · 0.85

Calls 3

clearMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected