Write

Fill a cozip_entry_t[] with arc names, payload sizes, and source paths, mark each one in_index = true so it lands in the cozip index, then hand the array to cozip_finalize. Capacity must be n_entries + 1 to leave room for the optional padding entry.

#include <cozip.h>
#include <stdio.h>

int main(void) {
    const char *names[] = {"file_0.bin", "file_1.bin", "file_2.bin"};
    const char *paths[] = {"/tmp/file_0.bin", "/tmp/file_1.bin", "/tmp/file_2.bin"};
    uint64_t sizes[3];

    /* three tmp files with anything inside */
    for (int i = 0; i < 3; i++) {
        FILE *f = fopen(paths[i], "wb");
        for (int j = 0; j < 100; j++) fprintf(f, "file %d contents\n", i);
        sizes[i] = (uint64_t)ftell(f);
        fclose(f);
    }

    /* one entry per file, all marked priority so the cozip index lists them.
       capacity = n_entries + 1, the extra slot is for the optional padding entry. */
    cozip_entry_t entries[4] = {0};
    for (int i = 0; i < 3; i++) {
        entries[i].arc_name      = names[i];
        entries[i].payload_size  = sizes[i];
        entries[i].in_index      = true;
        entries[i].source.kind   = COZIP_SOURCE_PATH;
        entries[i].source.u.path = paths[i];
    }

    cozip_error_t err;
    cozip_status_t s = cozip_finalize(
        "dataset.zip", entries, 3, 4, COZIP_PROFILE_NONE, &err);

    if (s != COZIP_OK) {
        fprintf(stderr, "cozip_finalize failed: %s\n", err.message);
        return 1;
    }
    return 0;
}

Build and run

Link against libcozip from ./build after running make lib.

# headers under ./include, library under ./build
cc -o write write.c -I./include -L./build -lcozip
./write