From 58245585cbe77e6c03ebe13f29e10393ff3c45b4 Mon Sep 17 00:00:00 2001 From: quou Date: Sun, 22 Dec 2024 22:19:36 +1100 Subject: cute asset loading system --- qstd/pack.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 qstd/pack.h (limited to 'qstd/pack.h') diff --git a/qstd/pack.h b/qstd/pack.h new file mode 100644 index 0000000..447cd5b --- /dev/null +++ b/qstd/pack.h @@ -0,0 +1,40 @@ +#ifndef pack_h +#define pack_h + +#include + +struct Arena; +struct Pack_File; + +typedef struct { + char name[56]; + uint32_t offset; + uint32_t size; +} Pack_Entry; + +typedef struct Pack { + char* filename; + uint32_t file_count; +} Pack; + +Pack_Entry* pack_find_entry(Pack* p, const char* name); +Pack_Entry* get_pack_table(Pack* p); +int get_pack_size(int entry_count); + +Pack* pack_open(const char* filename, struct Arena* a); +void pack_close(Pack* p); +Pack_Entry* pack_get_entry(Pack* p, const char* name); + +typedef enum { + seek_rel_cur, + seek_rel_start, + seek_rel_end +} Seek_Rel; + +struct Pack_File* pack_open_file(Pack* p, const char* name); +void pack_close_file(struct Pack_File* h); +int pack_read(struct Pack_File* f, void* buf, int size); +void pack_seek(struct Pack_File* f, int offset, Seek_Rel rel); +int pack_tell(struct Pack_File* f); + +#endif -- cgit v1.2.3-54-g00ecf