Sample code for 30+ languages & platforms
Zig

Check if a File is in Gzip Format

See more Gzip Examples

This example demonstrates how to use the ExamineFile method to determine whether a file is in Gzip format.

The method inspects the contents of the specified file and returns true if the file is recognized as a valid Gzip file, or false if it is not. This is useful for validating input files before attempting to decompress them.

If the method fails (for example, if the file does not exist or cannot be accessed), the CHECK_SUCCESS macro reports the error.

Chilkat Zig Downloads

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

pub fn main() !void {
    // This example demonstrates how to determine if a file is in Gzip format.

    const gzip = try chilkat.Gzip.init();
    defer gzip.deinit();

    // The file to examine:

    // Check if the file is a valid Gzip file:
ERROR: Method not in the Zig package: Gzip.ExamineFile
ERROR: Method not in the Zig package: Gzip.ExamineFile
    const is_gzip = gzip.ERROR();

    if (is_gzip) {
        std.debug.print("The file is a valid Gzip file.\n", .{});
    } else {
        std.debug.print("The file isnot a Gzip file.\n", .{});
    }
}