API Reference
Types
LibZip.ZipTools.ZipFile
— TypeZipFile
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.
LibZip.ZipTools.ZipArchive
— TypeZipArchive
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.
LibZip.ZipTools.ZipArchive
— MethodZipArchive(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
[...]
IO
LibZip.ZipTools.zip_open
— Functionzip_open(path::String; flags::Int = LIBZIP_RDONLY) -> ZipArchive
Open a zip archive file by its path
with specified flags
.
See also Open flags
section.
Base.close
— Functionclose(zip::ZipArchive)
Commit changes and close a zip
archive instance.
Base.read
— Functionread(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 defaultLIBZIP_FL_ENC_GUESS
).password::Union{Nothing,AbstractString}
: Password for an encrypted entry (by defaultnothing
).
See also Read file flags
section.
Base.read!
— Functionread!(zip::ZipArchive) -> Vector{UInt8}
Read binary data of the entire zip
archive.
Base.write
— Functionwrite(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
— Functionzip_discard(zip::ZipArchive)
Close a zip
archive instance without saving changes.
LibZip.ZipTools.zip_compress_file!
— Functionzip_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.
LibZip.ZipTools.zip_encrypt_file!
— Functionzip_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.
LibZip.ZipTools.zip_default_password!
— Functionzip_default_password!(zip::ZipArchive, password::String)
Set the default password
in the zip
archive used when accessing encrypted files.
LibZip.ZipTools.zip_add_dir!
— Functionzip_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
— Functionzip_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.
Base.length
— Functionlength(zip::ZipArchive, flags::UInt32 = LIBZIP_FL_ENC_GUESS)
Return the number of files in zip
archive.
See also Read file flags
section.