MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/FleX / LoadFileToBuffer

Function LoadFileToBuffer

core/platform.cpp:194–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192
193
194uint8_t* LoadFileToBuffer(const char* filename, uint32_t* sizeRead)
195{
196 FILE* file = fopen(filename, "rb");
197 if (file)
198 {
199 fseek(file, 0, SEEK_END);
200 long p = ftell(file);
201
202 uint8_t* buf = new uint8_t[p];
203 fseek(file, 0, SEEK_SET);
204 uint32_t len = uint32_t(fread(buf, 1, p, file));
205
206 fclose(file);
207
208 if (sizeRead)
209 {
210 *sizeRead = len;
211 }
212
213 return buf;
214 }
215 else
216 {
217 std::cout << "Could not open file for reading: " << filename << std::endl;
218 return NULL;
219 }
220}
221
222string LoadFileToString(const char* filename)
223{

Callers 1

LoadFileToStringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected