mk_zip_closefunction
void mk_zip_close(mk_zip_t *zip)Close a ZIP archive.
| Parameter | Type | Description |
|---|---|---|
zip | mk_zip_t * | Value for zip. |
#include <modkit/zip.h>11 functions · 1 typedefs
ZIP archive reading for texture packs and asset bundles.
Provides simple API for reading files from ZIP archives, designed for loading Polyhaven-style texture packs (GLTF + textures). Usage:
mk_zip_closefunctionvoid mk_zip_close(mk_zip_t *zip)Close a ZIP archive.
| Parameter | Type | Description |
|---|---|---|
zip | mk_zip_t * | Value for zip. |
mk_zip_existsfunctionbool mk_zip_exists(mk_zip_t *zip, const char *name)Check if a file exists in the archive.
| Parameter | Type | Description |
|---|---|---|
zip | mk_zip_t * | Archive handle |
name | const char * | File path within the archive |
Returns true if file exists
mk_zip_file_countfunctionint mk_zip_file_count(mk_zip_t *zip)Get the number of files in the archive.
| Parameter | Type | Description |
|---|---|---|
zip | mk_zip_t * | Value for zip. |
Returns The resulting value.
mk_zip_file_namefunctionconst char * mk_zip_file_name(mk_zip_t *zip, int index)Get the name of a file by index.
| Parameter | Type | Description |
|---|---|---|
zip | mk_zip_t * | Archive handle |
index | int | File index (0 to file_count-1) |
Returns File name, or NULL if index is out of range
mk_zip_file_sizefunctionsize_t mk_zip_file_size(mk_zip_t *zip, const char *name)Get the uncompressed size of a file.
| Parameter | Type | Description |
|---|---|---|
zip | mk_zip_t * | Archive handle |
name | const char * | File path within the archive |
Returns Size in bytes, or 0 if file not found
mk_zip_findfunctionint mk_zip_find(mk_zip_t *zip, const char *pattern, const char **out_names, int max_names)Find files matching a pattern (glob-style).
Patterns support * (any characters) and ? (single character).
| Parameter | Type | Description |
|---|---|---|
zip | mk_zip_t * | Archive handle |
pattern | const char * | Glob pattern, for example textures/(wildcard).jpg |
out_names | const char ** | Array to receive file names (can be NULL to just count) |
max_names | int | Maximum number of names to return |
Returns Number of matching files
mk_zip_freefunctionvoid mk_zip_free(void *data)Free memory allocated by mk_zip_read().
| Parameter | Type | Description |
|---|---|---|
data | void * | Data buffer. |
mk_zip_openfunctionmk_zip_t * mk_zip_open(const char *path)Open a ZIP archive for reading.
| Parameter | Type | Description |
|---|---|---|
path | const char * | Path to the ZIP file |
Returns Handle to the archive, or NULL on failure
mk_zip_open_memfunctionmk_zip_t * mk_zip_open_mem(const void *data, size_t size)Open a ZIP archive from memory.
| Parameter | Type | Description |
|---|---|---|
data | const void * | Pointer to ZIP data in memory |
size | size_t | Size of the data in bytes |
Returns Handle to the archive, or NULL on failure
mk_zip_readfunctionvoid * mk_zip_read(mk_zip_t *zip, const char *name, size_t *out_size)Read a file from the archive.
| Parameter | Type | Description |
|---|---|---|
zip | mk_zip_t * | Archive handle |
name | const char * | File path within the archive |
out_size | size_t * | Pointer to receive the size of the data (can be NULL) |
Returns Allocated buffer with file contents, or NULL on failure
mk_zip_read_intofunctionint mk_zip_read_into(mk_zip_t *zip, const char *name, void *buf, size_t buf_size)Read a file from the archive into an existing buffer.
| Parameter | Type | Description |
|---|---|---|
zip | mk_zip_t * | Archive handle |
name | const char * | File path within the archive |
buf | void * | Buffer to read into |
buf_size | size_t | Size of the buffer |
Returns Number of bytes read, or -1 on failure
mk_zip_ttypedeftypedef struct mk_zip mk_zip_tType used for zip.