Modules

Zip_File_Directory

moduleSource

Available on macOS, Linux, Windows, Wasm

#import "Zip_File_Directory";

Procedures#

(zip_filename: string, close_file := true) -> (success: bool, dir: Zip_Directory)

Reads the central directory of a zip file. Returns false when the file cannot be opened or is not a classic zip (zip64 archives and entries with a trailing data descriptor are refused). Call deinit on the result. The file is closed afterwards unless close_file is false.

ok, dir := load_zip_directory("assets.zip");
if ok {
    defer deinit(*dir);
    for dir.entries print("%\n", it.filename);
}
↗

This one is only checked to compile, not run.

Types#

:: struct

One file in a zip archive, as its central directory describes it. Most fields are the zip format's own; filename points into the directory's memory_block.

filename: string
position_in_file: s64
version_made_by: u16
version_needed_to_extract: u16
bit_flag: u16
crc: u32
compressed_len: u32
chunk_len: u32
name_len: u16
extra_field_len: u16
file_comment_len: u16
internal_attributes: u16
external_attributes: u32
chunk_offset: u32
:: struct

The list of files in a zip archive, read without extracting anything.

name: := ""
entries: [..] Zip_Entry
memory_block: string
file: File