...
This commit is contained in:
14
vendors/file_utils/file_utils.c
vendored
Normal file
14
vendors/file_utils/file_utils.c
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
unsigned char* read_file_bytes(const char* path, int* out_size) {
|
||||
FILE* f = fopen(path, "rb");
|
||||
if (!f) return 0;
|
||||
fseek(f, 0, SEEK_END);
|
||||
*out_size = (int)ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
unsigned char* buf = (unsigned char*)malloc(*out_size);
|
||||
fread(buf, 1, *out_size, f);
|
||||
fclose(f);
|
||||
return buf;
|
||||
}
|
||||
Reference in New Issue
Block a user