summaryrefslogtreecommitdiff
path: root/qstd/pack.h
blob: 447cd5beed6f67f298ab7bb38862e3deba2bda48 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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