API Reference
Types
LibZip.ZipTools.ZipFile — Type
ZipFileRepresents 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.
LibZip.ZipTools.ZipArchive — Type
ZipArchiveType 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.
LibZip.ZipTools.ZipArchive — Method
ZipArchive(data::Vector{UInt8}; flags::Integer = LIBZIP_RDONLY) -> ZipArchive
ZipArchive(; flags::Integer = LIBZIP_CREATE) -> ZipArchiveConstruct 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
[...]IO
LibZip.ZipTools.zip_open — Function
zip_open(path::String; flags::Integer = LIBZIP_RDONLY) -> ZipArchiveOpen a zip archive file by its path with specified flags.
See also Open flags section.
Base.close — Function
close(zip::ZipArchive)Commit changes and close a zip archive instance.
Base.read — Function
read(zip::ZipArchive, index::Integer; 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 defaultLIBZIP_FL_ENC_GUESS).password::Union{Nothing,AbstractString}: Password for an encrypted entry (by defaultnothing).
See also Read file flags section.
Base.read! — Function
read!(zip::ZipArchive) -> Vector{UInt8}Read binary data of the entire zip archive.
Base.write — Function
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.
write(path::String, zip::ZipArchive)Write the zip archive binary data as a file by path.
Tools
LibZip.ZipTools.zip_discard — Function
zip_discard(zip::ZipArchive)Close a zip archive instance without saving changes.
LibZip.ZipTools.zip_compress_file! — Function
zip_compress_file!(zip::ZipArchive, index::Integer, method::Integer = LIBZIP_CM_DEFAULT; compression_level::Integer = 1)
zip_compress_file!(zip::ZipArchive, filename::String, method::Integer = LIBZIP_CM_DEFAULT; compression_level::Integer = 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.
LibZip.ZipTools.zip_encrypt_file! — Function
zip_encrypt_file!(zip::ZipArchive, index::Integer, 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.
LibZip.ZipTools.zip_default_password! — Function
zip_default_password!(zip::ZipArchive, password::String)Set the default password in the zip archive used when accessing encrypted files.
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.
LibZip.ZipTools.zip_get_file_info — Function
zip_get_file_info(zip::ZipArchive, filename::String; flags::UInt32 = LIBZIP_FL_ENC_GUESS)
zip_get_file_info(zip::ZipArchive, index::Integer; flags::UInt32 = LIBZIP_FL_ENC_GUESS)Return information about the filename in a zip archive.
See also File info flags section.
Base.length — Function
length(zip::ZipArchive, flags::UInt32 = LIBZIP_FL_ENC_GUESS)Return the number of files in zip archive.
See also Read file flags section.