Sample code for 30+ languages & platforms
Zig

.Z File Compression

See more Zip Examples

Use LZW compression to create a .Z compressed file. Compresses any single file into a .Z format compressed file.

(Chilkat's .Z compression functionality is included as part of the Chilkat Zip license.)

Chilkat Zig Downloads

Zig
const std = @import("std");
const chilkat = @import("chilkat");

pub fn main(init: std.process.Init) !void {
    const alloc = init.arena.allocator();

    var success: bool = false;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    const uc = try chilkat.UnixCompress.init();
    defer uc.deinit();

    success = if (uc.compressFile("hamlet.xml", "hamlet.xml.Z")) true else |_| false;
    if (!success) {
        std.debug.print("{s}\n", .{try uc.getLastErrorText(alloc)});
    } else {
        std.debug.print("Success.\n", .{});
    }
}