MCPcopy Index your code
hub / github.com/assaultcube/AC / loadfile

Function loadfile

source/src/stream.cpp:1091–1109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1089}
1090
1091char *loadfile(const char *fn, int *size, const char *mode)
1092{
1093 stream *f = openfile(fn, mode ? mode : "rb");
1094 if(!f) return NULL;
1095 int len = f->size();
1096 if(len<=0) { delete f; return NULL; }
1097 char *buf = new char[len+1];
1098 if(!buf) { delete f; return NULL; }
1099 buf[len] = 0;
1100 int rlen = f->read(buf, len);
1101 delete f;
1102 if(len!=rlen && (!mode || strchr(mode, 'b')))
1103 {
1104 delete[] buf;
1105 return NULL;
1106 }
1107 if(size!=NULL) *size = len;
1108 return buf;
1109}
1110
1111int streamcopy(stream *dest, stream *source, int maxlen)
1112{

Callers 15

certMethod · 0.85
cmpfFunction · 0.85
loadMethod · 0.85
loadMethod · 0.85
trypreloadMethod · 0.85
entropy_initFunction · 0.85
ed25519testFunction · 0.85
savepreprivkeyFunction · 0.85
saveprivkeyFunction · 0.85
authkey_Function · 0.85
execfileFunction · 0.85
readmapFunction · 0.85

Calls 3

openfileFunction · 0.85
sizeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected