Z64 (Z64 v0.1.0)

View Source

Z64 is a high-performance Elixir library for decoding ZIP files, specifically supporting PKWARE's Deflate64 (Compression Method 9) decompression, which is not natively supported by OTP's :zip module.

Summary

Functions

Extracts and decompresses a specific file by its filename from the ZIP archive. Accepts either a file path or a binary containing ZIP data.

Lists all file entries inside the given ZIP archive. Accepts either a file path or a binary containing ZIP data.

Unzips all file entries from the ZIP archive and writes them into output_dir. Accepts either a file path or a binary containing ZIP data.

Functions

extract_entry(zip_binary_or_path, filename)

@spec extract_entry(String.t() | binary(), String.t()) ::
  {:ok, binary()} | {:error, term()}

Extracts and decompresses a specific file by its filename from the ZIP archive. Accepts either a file path or a binary containing ZIP data.

Returns {:ok, decompressed_binary} or {:error, reason}.

list_entries(zip_binary_or_path)

@spec list_entries(String.t() | binary()) :: {:ok, [Z64.Entry.t()]} | {:error, term()}

Lists all file entries inside the given ZIP archive. Accepts either a file path or a binary containing ZIP data.

Returns {:ok, [%Z64.Entry{filename: "file.txt", compressed_size: 100, uncompressed_size: 200, compression_method: 9, ...}]} or {:error, reason}.

unzip(zip_binary_or_path, output_dir)

@spec unzip(String.t() | binary(), String.t()) :: :ok | {:error, term()}

Unzips all file entries from the ZIP archive and writes them into output_dir. Accepts either a file path or a binary containing ZIP data.

Returns :ok or {:error, reason}.