feat: add public API header and format spec
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
#ifndef FPK_H
|
||||
#define FPK_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define FPK_MAGIC "FPK1"
|
||||
#define FPK_MAGIC_SIZE 4
|
||||
#define FPK_VERSION 1
|
||||
|
||||
#define FPK_HEADER_SIZE 28
|
||||
/*
|
||||
* magic 4
|
||||
* entry_count 8
|
||||
* dir_offset 8
|
||||
* strtab_offset 8
|
||||
* --
|
||||
* 28
|
||||
*/
|
||||
#define FPK_DIR_ENTRY_SIZE 25
|
||||
/*
|
||||
* path_offset 8
|
||||
* data_offset 8
|
||||
* data_size 8
|
||||
* method 1
|
||||
* --
|
||||
* 25
|
||||
*/
|
||||
|
||||
#define FPK_METHOD_STORE 0
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
const char *path;
|
||||
uint64_t data_offset;
|
||||
uint64_t data_size;
|
||||
uint8_t method;
|
||||
} fpk_entry_t;
|
||||
|
||||
struct fpk;
|
||||
struct fpk_writer;
|
||||
|
||||
struct fpk *fpk_open(const char *path);
|
||||
void fpk_close(struct fpk *fpk);
|
||||
fpk_entry_t *fpk_find(struct fpk *fpk, const char *path);
|
||||
void *fpk_read(struct fpk *fpk, const fpk_entry_t *entry, size_t *out_size);
|
||||
uint64_t fpk_entry_count(const struct fpk *fpk);
|
||||
const fpk_entry_t *fpk_entry_at(const struct fpk *fpk, uint64_t index);
|
||||
|
||||
struct fpk_writer *fpk_writer_open(const char *path);
|
||||
int fpk_writer_add(struct fpk_writer *w, const char *path, const void *data,
|
||||
size_t size);
|
||||
int fpk_writer_finalize(struct fpk_writer *w);
|
||||
void fpk_writer_close(struct fpk_writer *w);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FPK_H */
|
||||
Reference in New Issue
Block a user