4coder/custom/4coder_file.cpp

30 lines
548 B
C++
Raw Normal View History

2019-10-03 23:00:31 +00:00
/*
* Mr. 4th Dimention - Allen Webster
*
* 03.10.2019
*
* Basic helpers for C std file handling.
*
*/
// TOP
#include <stdio.h>
function String_Const_u8
2020-11-24 06:27:33 +00:00
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, result.size, file);
result.str[result.size] = 0;
}
return(result);
2019-10-03 23:00:31 +00:00
}
// BOTTOM