#include #include #include "util.hpp" bool read_file(array* out, const char* filepath) { FILE* fp = NULL; if (fopen_s(&fp, filepath, "rb") != 0) { printf("ERROR Failed to open file %s\n", filepath); return false; } fseek(fp, 0L, SEEK_END); size_t sz = ftell(fp); fseek(fp, 0, SEEK_SET); char *data = (char*)malloc(sizeof(char)*sz); fread(data, sizeof(char), sz, fp); fclose(fp); out->data = data; out->len = sz; return true; }