Skip to content

Latest commit

 

History

History
38 lines (29 loc) · 1.09 KB

File metadata and controls

38 lines (29 loc) · 1.09 KB

zip.zig

A Zig library to work with zip files.

This is an experimental library and not meant for production use. The only place where this has been used is zigverm.

Adding it to your project

  • Add zip.zig to your dependencies
zig fetch --save https://github.com/AMythicDev/zip.zig/archive/refs/tags/v[VERSION].tar.gz
  • In your build.zig:
pub fn build(b: *std.Build) !void {
// Get the dependency into your build.zig
const zip = b.dependency("zip", .{});
// Add import to all your compile targets
test_exe.root_module.addImport("zip", zip.module("zip"));

Basic Usage

Open a zip file and list its members

    const file = try std.fs.File.openFile("myzip.zip", .{});

    const zipfile = try ZipArchive.openFromStreamSource(alloc, @constCast(&std.io.StreamSource{ .file = file }));

    var m_iter = zipfile.members.iterator();
    while (m_iter.next()) |i| {
        std.debug.print("{s}", i.key_ptr.*);
    }

License

The project is licensed under Apache 2.0 License.