68 lines
1.4 KiB
C
68 lines
1.4 KiB
C
#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);
|
|
|
|
typedef int (*fpk_add_dir_cb)(const char *path, uint64_t size, void *ctx);
|
|
int fpk_writer_add_dir(struct fpk_writer *w, const char *dir_path,
|
|
fpk_add_dir_cb on_add, void *ctx);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* FPK_H */
|