aboutsummaryrefslogtreecommitdiffstats
path: root/build/4coder_byp/custom/4coder_file.cpp
blob: 7910806280f2b0c19ec280ff8136512d8adf4a5a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
 * Mr. 4th Dimention - Allen Webster
 *
 * 03.10.2019
 *
 * Basic helpers for C std file handling.
 *
 */

// TOP

#include <stdio.h>

function String_Const_u8
data_from_file(Arena *arena, FILE *file){
 String_Const_u8 result = {};
 if (file != 0){
 fseek(file, 0, SEEK_END);
 result.size = ftell(file);
 fseek(file, 0, SEEK_SET);
 result.str = push_array(arena, u8, result.size + 1);
 fread(result.str, 1, (size_t)result.size, file);
 result.str[result.size] = 0;
 }
 return(result);
}

// BOTTOM