#ifndef GUARD_5B2A3676BBB85E5075C01FF213126C89
#define GUARD_5B2A3676BBB85E5075C01FF213126C89

#include "types.h"
#include <stdio.h>

struct sw_filebuffer {
	u32 pos;
	u32 size;
	u8 *_data;
};

/* TODO: use skunkworks overlay paths */
u8 *sw_file_load(char *path, u32 *out_size);

struct sw_filebuffer *sw_filebuffer_create(u32 size);
struct sw_filebuffer *sw_filebuffer_load(char *path);
void sw_filebuffer_destroy(struct sw_filebuffer *buf);

void sw_filebuffer_read(struct sw_filebuffer *buf, void *dst, u32 count);

/* fwrite helpers */

void sw_fwrite_u8(FILE *fil, u8 val);
void sw_fwrite_i8(FILE *fil, i8 val);
void sw_fwrite_u16(FILE *fil, u16 val);
void sw_fwrite_i16(FILE *fil, u16 val);
void sw_fwrite_u32(FILE *fil, u32 val);
void sw_fwrite_i32(FILE *fil, u32 val);
void sw_fwrite_u64(FILE *fil, u64 val);
void sw_fwrite_i64(FILE *fil, u64 val);
void sw_fwrite_f32(FILE *fil, f32 val);
void sw_fwrite_f64(FILE *fil, f64 val);
void sw_fwrite_bool(FILE *fil, bool val);

void sw_fwrite_str_nozero(FILE *fil, char *str);
void sw_fwrite_str_zero(FILE *fil, char *str);
void sw_fwrite_str_prefix8(FILE *fil, char *str);
void sw_fwrite_str_prefix16(FILE *fil, char *str);
void sw_fwrite_str_prefix32(FILE *fil, char *str);

#endif /* GUARD_5B2A3676BBB85E5075C01FF213126C89 */
