refactoring

This commit is contained in:
2025-08-17 12:40:31 -05:00
parent 47564bb3cf
commit 2a1654e80c
13 changed files with 120 additions and 1901 deletions

View File

@@ -3,21 +3,21 @@
#include "util.hpp"
bool read_file(Array<char>* out, const char* filepath) {
bool read_file(array<char>* out, const char* filepath) {
FILE* fp = NULL;
if (fopen_s(&fp, filepath, "r") != 0) {
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, 0L, 0L);
fseek(fp, 0, SEEK_SET);
char *data = (char*)malloc(sizeof(char)*sz);
fread(data, sizeof(char), sz, fp);
fclose(fp);
out->_data = data;
out->data = data;
out->len = sz;
return true;
}