package core:compress/gzip

⌘K
Ctrl+K
or
/

    Overview

    A small GZIP unpacker.

    This package is deprecated, use core:compress/deflate as the example below does.

    Example:
    package compress_gzip_example
    
    import "core:compress"
    import "core:compress/deflate"
    import "core:fmt"
    import "core:os"
    
    // Small GZIP file with fextra, fname and fcomment present.
    @private
    TEST: []u8 = {
    	0x1f, 0x8b, 0x08, 0x1c, 0xcb, 0x3b, 0x3a, 0x5a,
    	0x02, 0x03, 0x07, 0x00, 0x61, 0x62, 0x03, 0x00,
    	0x63, 0x64, 0x65, 0x66, 0x69, 0x6c, 0x65, 0x6e,
    	0x61, 0x6d, 0x65, 0x00, 0x54, 0x68, 0x69, 0x73,
    	0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x63, 0x6f,
    	0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x00, 0x2b, 0x48,
    	0xac, 0xcc, 0xc9, 0x4f, 0x4c, 0x01, 0x00, 0x15,
    	0x6a, 0x2c, 0x42, 0x07, 0x00, 0x00, 0x00,
    }
    
    main :: proc() {
    	// Set up output buffer.
    	buf: [dynamic]byte
    	defer delete(buf)
    
    	stdout :: proc(s: string) {
    		os.write_string(os.stdout, s)
    	}
    	stderr :: proc(s: string) {
    		os.write_string(os.stderr, s)
    	}
    
    	if len(os.args) < 2 {
    		stderr("No input file specified.\n")
    		err := deflate.inflate_gzip(&buf, TEST)
    		if err == nil {
    			stdout("Displaying test vector: \"")
    			stdout(string(buf[:]))
    			stdout("\"\n")
    		} else {
    			fmt.printf("deflate.inflate_gzip returned %v\n", err)
    		}
    		delete(buf)
    		os.exit(0)
    	}
    
    	for file in os.args[1:] {
    		clear(&buf)
    		err: deflate.Error
    
    		if file == "-" {
    			// Read from stdin
    			ctx := compress.init_context(os.to_stream(os.stdin), &buf)
    			defer compress.destroy_context(&ctx)
    			err = deflate.inflate_gzip(&ctx)
    		} else {
    			data, read_err := os.read_entire_file(file, context.allocator)
    			defer delete(data)
    			if read_err != nil {
    				stderr("File not found: ")
    				stderr(file)
    				stderr("\n")
    				os.exit(1)
    			}
    			err = deflate.inflate_gzip(&buf, data)
    		}
    		if err != nil {
    			stderr("GZIP returned an error.\n")
    			os.exit(2)
    		}
    		stdout(string(buf[:]))
    	}
    }
    

    An implementation of the GZIP wrapper over the Deflate algorith. Deprecated, folded into core:compress/deflate.

    Index

    Variables (0)

    This section is empty.

    Procedure Groups (1)

    Types

    Error ¶

    Error :: compress.Error

    Related Procedures With Returns

    Header :: compress_deflate.Gzip_Header

    Magic ¶

    Magic :: compress_deflate.Gzip_Magic

    OS ¶

    OS :: compress_deflate.Gzip_OS

    Constants

    GZIP_MAX_PAYLOAD_SIZE ¶

    GZIP_MAX_PAYLOAD_SIZE: i64 : deflate.GZIP_MAX_PAYLOAD_SIZE

    OS_Name ¶

    OS_Name: [compress_deflate.Gzip_OS]string : deflate.GZIP_OS_NAME

    Variables

    This section is empty.

    Procedures

    load_from_bytes ¶

    Deprecated. Use deflate.inflate_gzip from core:compress/deflate
    @(deprecated="Use `deflate.inflate_gzip` from `core:compress/deflate`")
    load_from_bytes :: proc(
    	data:                 []u8, 
    	output:               ^bytes.Buffer, 
    	known_gzip_size:      int = -1, 
    	expected_output_size: int = -1, 
    	allocator := context.allocator, 
    ) -> (err: compress.Error) {…}

    load_from_context ¶

    Deprecated. Use deflate.inflate_gzip from core:compress/deflate
    @(deprecated="Use `deflate.inflate_gzip` from `core:compress/deflate`")
    load_from_context :: proc(
    	z:               ^compress.Context, 
    	known_gzip_size: int = -1, 
    	allocator := context.allocator, 
    ) -> (err: compress.Error) {…}

    load_from_file ¶

    Deprecated. Use [os.read_entire_file](/core/os/#read_entire_file) and deflate.inflate_gzip from core:compress/deflate
    @(deprecated="Use `os.read_entire_file` and `deflate.inflate_gzip` from `core:compress/deflate`")
    load_from_file :: proc(
    	filename:             string, 
    	output:               ^bytes.Buffer, 
    	expected_output_size: int = -1, 
    	allocator := context.allocator, 
    ) -> (err: compress.Error) {…}

    Procedure Groups

    Source Files

    Generation Information

    Generated with odin version dev-2026-11 (vendor "odin") Windows_amd64 @ 2026-11-10 03:07:04.374188700 +0000 UTC