123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdint.h>
- #include <check.h>
- #include "../util.h"
- int32_t read_file(const char *path, uint8_t **target){
- FILE *fp;
- int32_t fsize;
- fp = fopen(path, "rb");
- if (fp == NULL) {
- perror("fopen");
- return 0;
- }
- fseek(fp, 0, SEEK_END);
- fsize = ftell(fp);
- fseek(fp, 0, SEEK_SET);
- *target = smalloc(fsize);
- int32_t result = fread(*target, fsize, 1, fp);
- fclose(fp);
- return result;
- }
|