4coder/custom/4coder_file.cpp

30 lines
556 B
C++
Raw Permalink 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);
2021-01-24 23:30:57 +00:00
fread(result.str, 1, (size_t)result.size, file);
2020-11-24 06:27:33 +00:00
result.str[result.size] = 0;
}
return(result);
2019-10-03 23:00:31 +00:00
}
// BOTTOM