diff options
Diffstat (limited to 'teensy/common.c')
| -rw-r--r-- | teensy/common.c | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/teensy/common.c b/teensy/common.c deleted file mode 100644 index 4da4004..0000000 --- a/teensy/common.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "common.h" - -#include <stdarg.h> -#include <stdio.h> - -char *read_file(const char *path, size_t *size_out) -{ - FILE *file = fopen(path, "r"); - if (!file) - ty_log_fatal(TY_ERR_IO, "could not open file '%s'", path); - - fseek(file, 0L, SEEK_END); - size_t size = ftell(file); - rewind(file); - - char *dat = ty_alloc(sizeof(char) * (size + 1)); - - size_t bytes_read = fread(dat, sizeof(char), size, file); - - if (bytes_read < size) { - ty_log_fatal(TY_ERR_IO, "could not read file '%s'", path); - } - - fclose(file); - - if (size_out) - *size_out = size; - - return dat; -} |
