summaryrefslogtreecommitdiff
path: root/qstd/pack.h
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-12-22 22:19:36 +1100
committerquou <quou@disroot.org>2024-12-22 22:19:36 +1100
commit58245585cbe77e6c03ebe13f29e10393ff3c45b4 (patch)
tree6c3dcd8e9adcbc699318d4062bb2cf594116702e /qstd/pack.h
parent82767020e84ec8c1af2e3817fc7efede5497c82d (diff)
cute asset loading system
Diffstat (limited to 'qstd/pack.h')
-rw-r--r--qstd/pack.h40
1 files changed, 40 insertions, 0 deletions
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 <stdint.h>
+
+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