MCPcopy Create free account
hub / github.com/DFHack/dfhack / load_file

Function load_file

library/binpatch.cpp:195–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195bool load_file(std::vector<patch_byte> *pvec, std::string fname)
196{
197 FILE *f = fopen(fname.c_str(), "rb");
198 if (!f)
199 {
200 cerr << "Cannot open file: " << fname << endl;
201 return false;
202 }
203
204 fseek(f, 0, SEEK_END);
205 pvec->resize(ftell(f));
206 fseek(f, 0, SEEK_SET);
207 size_t cnt = fread(pvec->data(), 1, pvec->size(), f);
208 fclose(f);
209
210 return cnt == pvec->size();
211}
212
213bool save_file(const std::vector<patch_byte> &pvec, std::string fname)
214{

Callers 1

mainFunction · 0.70

Calls 4

c_strMethod · 0.80
resizeMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected