Write

Build a cozip_file_t[] with names and source paths, plan the FLAT layout, then write. Pass NULL for the metadata if you do not need a manifest.

#include <cozip.h>

int main(void) {
    const char *names[] = {"file_0001.bin", "file_0002.bin", "file_0003.bin"};
    const char *paths[] = {"/tmp/file_0001.bin", "/tmp/file_0002.bin", "/tmp/file_0003.bin"};

    cozip_file_t files[3];
    for (int i = 0; i < 3; i++) {
        files[i].name = names[i];
        files[i].path = paths[i];
    }

    cozip_plan plan;
    cozip_plan_flat(files, 3, &plan);
    cozip_write_flat("dataset.zip", &plan, files, 3, NULL, 0);
    cozip_plan_free(&plan);
    return 0;
}

Build and run

Link against libcozip after running make lib at the repo root.

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

Read

The C library is write-only. To read a cozip archive, use the DuckDB extension or one of the language bindings (Python, R, Julia).