#include "arc/std/io.h" #include "arc/std/errno.h" #include #include int32_t ARC_IO_FileToStr(const char *path, char **data, uint64_t *size){ FILE *file = fopen(path, "rb"); if(!file){ return ARC_ERRNO_NULL; } fseek(file, 0L, SEEK_END); *size = ftell(file); rewind(file); *data = (char *) calloc(1, *size + 1); if(!*data){ fclose(file); return ARC_ERRNO_NULL; } if(1 != fread(*data, *size, 1, file)){ fclose(file); return ARC_ERRNO_COPY; } fclose(file); return 0; }