API Reference

Types

LibZip.ZipTools.ZipFileType
ZipFile

Represents a file contained in an ZipArchive.

Fields

  • body::Vector{UInt8}: Binary representation of file contents.
  • name::String: File name.
  • index::Int64: File index number (zero-based).
  • size::Int64: File uncompressed size.
  • comp_size::Int64: File compressed size.
  • time::DateTime: File last modification time.
  • crc::Int64: File CRC-32 checksum.
  • comp_method::Int64: File compression method.
  • encryption_method::Int64: File encryption method.
source
LibZip.ZipTools.ZipArchiveType
ZipArchive

Type describing zip archive for reading and writing.

Fields

  • archive_ptr::Ptr{LibZipT}: The pointer to the C library zip structure.
  • source_ptr::Ptr{LibZipSourceT}: The pointer to the C library source structure.
  • comment::String: The archive's comment.
  • source_data::Vector{Vector{UInt8}}: A container to hold in-memory source data buffers for the archive.
  • closed::Bool: Flag indicating whether the archive is closed.
source
LibZip.ZipTools.ZipArchiveMethod
ZipArchive(data::Vector{UInt8}; flags::Int = LIBZIP_RDONLY) -> ZipArchive
ZipArchive(; flags::Int = LIBZIP_CREATE) -> ZipArchive

Construct an empty ZipArchive or an existing one from an in-memory byte buffer with specified flags.

See also Open flags section.

Examples

julia> ZipArchive(; flags = LIBZIP_CREATE | LIBZIP_CHECKCONS)
 ZipArchive:
    🔓 Archive is open and ready for use!
    📂 The archive is empty.
julia> zip_file = read(".../secrets.zip");

julia> ZipArchive(zip_file)
 ZipArchive:
    🔓 Archive is open and ready for use!
    📁 Files in archive:
      📄 my_secret_1.txt/: 42 bytes
      [...]
source

IO

Base.closeFunction
close(zip::ZipArchive)

Commit changes and close a zip archive instance.

source
Base.readFunction
read(zip::ZipArchive, index::Int; kw...) -> Vector{UInt8}
read(zip::ZipArchive, filename::String; kw...) -> Vector{UInt8}

Read the file contents of a zip archive by index or filename.

Keyword arguments

  • flags::UInt32: Mode for a reading and name lookup (by default LIBZIP_FL_ENC_GUESS).
  • password::Union{Nothing,AbstractString}: Password for an encrypted entry (by default nothing).

See also Read file flags section.

source
Base.read!Function
read!(zip::ZipArchive) -> Vector{UInt8}

Read binary data of the entire zip archive.

source
Base.writeFunction
write(zip::ZipArchive, filename::String, data::Vector{UInt8}; flags::UInt32 = LIBZIP_FL_OVERWRITE)

Write the binary data to a zip archive, which will be created if it does not exist yet or overwritten if it does exist.

See also Add file flags section.

source
write(path::String, zip::ZipArchive)

Write the zip archive binary data as a file by path.

source

Tools

LibZip.ZipTools.zip_compress_file!Function
zip_compress_file!(zip::ZipArchive, index::Int, method::Int = LIBZIP_CM_DEFAULT; compression_level::Int = 1)
zip_compress_file!(zip::ZipArchive, filename::String, method::Int = LIBZIP_CM_DEFAULT; compression_level::Int = 1)

Set the compression method for the file at position index or by filename in the zip archive. The compression_level argument defines the compression level.

See also Compression methods section.

source
LibZip.ZipTools.zip_encrypt_file!Function
zip_encrypt_file!(zip::ZipArchive, index::Int, password::String; method::UInt16 = LIBZIP_EM_AES_128)
zip_encrypt_file!(zip::ZipArchive, filename::String, password::String; method::UInt16 = LIBZIP_EM_AES_128)

Set the encryption method for the file at position index or by filename in the zip archive using the password.

See also encryption methods section.

source
LibZip.ZipTools.zip_add_dir!Function
zip_add_dir!(zip::ZipArchive, dirname::String; flags::UInt32 = LIBZIP_FL_OVERWRITE)

Add a directory to a zip archive by the dirname, which will be created if it does not exist yet or overwritten if it does exist.

See also Add file flags section.

source
LibZip.ZipTools.zip_get_file_infoFunction
zip_get_file_info(zip::ZipArchive, filename::String; flags::UInt32 = LIBZIP_FL_ENC_GUESS)
zip_get_file_info(zip::ZipArchive, index::Int; flags::UInt32 = LIBZIP_FL_ENC_GUESS)

Return information about the filename in a zip archive.

See also File info flags section.

source
Base.lengthFunction
length(zip::ZipArchive, flags::UInt32 = LIBZIP_FL_ENC_GUESS)

Return the number of files in zip archive.

See also Read file flags section.

source