···1212#include <stdint.h>
1313#include <stdbool.h>
14141515+typedef enum BindleCompress {
1616+ BindleCompressNone,
1717+ BindleCompressZstd,
1818+} BindleCompress;
1919+1520typedef struct Bindle Bindle;
16212222+/**
2323+ * Open a bindle file from disk, the path paramter should be NUL terminated
2424+ */
1725struct Bindle *bindle_open(const char *path);
18261927/**
2020- * Adds a new entry. Returns true on success.
2828+ * Adds a new entry, the name should be NUL terminated, will the data can contain NUL characters since the length
2929+ * is provided
2130 */
2231bool bindle_add(struct Bindle *ctx,
2332 const char *name,
2433 const uint8_t *data,
2534 size_t data_len,
2626- bool compress);
3535+ enum BindleCompress compress);
27362837/**
2929- * Commits changes to disk.
3838+ * Save any changed to disk
3039 */
3140bool bindle_save(struct Bindle *ctx);
32413342/**
3434- * Frees BindleContext
4343+ * Close an open bindle file
3544 */
3645void bindle_close(struct Bindle *ctx);
37464747+/**
4848+ * Read a value from a bindle file in memory, returns a pointer that should be freed with
4949+ * `bindle_free_buffer`
5050+ */
3851uint8_t *bindle_read(struct Bindle *ctx_ptr, const char *name, size_t *out_len);
39525353+/**
5454+ * Used to free the results from `bindle_read`
5555+ */
4056void bindle_free_buffer(uint8_t *ptr);
41575858+/**
5959+ * Directly read an uncompressed entry from disk, returns NULL if the entry is compressed or doesn't exist
6060+ */
4261const uint8_t *bindle_read_uncompressed_direct(struct Bindle *ctx,
4362 const char *name,
4463 size_t *out_len);
45646565+/**
6666+ * Get the number of entries in a bindle file
6767+ */
4668size_t bindle_length(const struct Bindle *ctx);
47694870/**
···5173 */
5274const char *bindle_entry_name(const struct Bindle *ctx, size_t index, size_t *len);
53757676+/**
7777+ * Compact and rewrite bindle file
7878+ */
5479bool bindle_vacuum(struct Bindle *ctx);
55805681#endif /* BINDLE_H */