| 192 | |
| 193 | |
| 194 | uint8_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 | |
| 222 | string LoadFileToString(const char* filename) |
| 223 | { |