LIBZIP(3)
β¨ LIBZIP(3) β¨
okay bestie, welcome to the Library Functions Manual π this is libzip, and she is that girl.
π NAME π
libzip β the library for manipulating zip archives ποΈβ¨
π LIBRARY π
libzip (-lzip) β link her up, she's ready π«Ά
π SYNOPSIS π
#include <zip.h>
that's it. that's the whole vibe check. one include and you're in π
πΈ DESCRIPTION πΈ
libzip is a library for reading, creating, and modifying zip archives. iconic behavior, no cap.
The main design criteria for libzip were, and I quote, the sacred texts:
- Maintain a stable API without breaking backwards compatibility.
- Do not create corrupt files, even in case of errors.
- Do not delete data.
- Be efficient. β‘
For this reason, when you're modifying zip archives, libzip writes to a temporary file and replaces the original zip archive atomically. it's giving main character energy, it's giving "I will not ruin your data," periodt. π
π«Ά GENERAL NOTES π«Ά
When you add files to an archive, the file data is only read when the new archive is written. So like β every file you added has to stay valid until the archive is closed with zip_close(3) or zip_discard(3). don't go deleting stuff out from under her, bestie π
Unless explicitly documented, functions should not be passed NULL pointers as arguments. fr fr. don't do it.
π¦ DATA TYPES π¦
These data types correspond to central concepts in libzip. Most of them are private, meaning you can't allocate them or access their members directly. and honestly? that's a flex β it lets them extend the structures in the future without breaking compatibility. forward thinking, we love to see it π
π zip_t
This type represents an opened archive. See zip(5).
π zip_file_t
This type represents a file from an archive that has been opened for reading. See zip_file(5).
π zip_source_t
This type represents a source (or destination) of data. It's used in libzip for providing data when adding or replacing files, accessing data from a file inside an archive, and the data for the archive as a whole. See zip_source(5).
π zip_error_t
This type represents information about an error. Its type can be checked against pre-defined constants and it can be converted to a human readable string. See zip_error(5).
π FILE NAMES π
π Encoding
Names of files in the host file system are expected in UTF-8 encoding. On Windows, variants for ASCII and UTF-16 are also available.
Names of files inside archives are by default expected in UTF-8 encoding. Other encodings can be requested by using the flags ZIP_FL_ENC_CP437 and ZIP_FL_ENC_RAW.
For details see the relevant man pages. iykyk π
π Directory Separator
The zip format requires the use of forward slash (/) as directory separator. Since backslash (\) can be part of a valid file name on Unix systems, libzip does not automatically convert them, even on Windows. It is the responsibility of the programmer to ensure that all directory separators are passed as forward slashes to libzip. so like, that's on you bestie π
β THREAD SAFETY β
In general, different zip archives opened by libzip are independent of each other and can be used by parallel-running threads without locking. slay.
If you want to use an archive from multiple threads, you have to synchronize access to it yourself. And if you use an archive as a source for zip_file_add(3) or zip_file_replace(3), access to the target archive must be synchronized with access to the source archive as well. don't get it twisted π
π READING ZIP ARCHIVES π
π Open Archive
π Get Archive Attributes
π Find Files
π Read Files
zip_fopen(3)zip_fopen_encrypted(3)zip_fopen_index(3)zip_fopen_index_encrypted(3)zip_fread(3)zip_file_is_seekable(3)zip_fseek(3)(uncompressed files only)zip_ftell(3)zip_fclose(3)
π Close Archive
π Get File Attributes
π Miscellaneous
π₯ CREATING/MODIFYING ZIP ARCHIVES π₯
πΈ Create/Open Archive
πΈ Add/Change Files and Directories
zip_dir_add(3)zip_file_add(3)zip_file_replace(3)zip_file_set_comment(3)zip_file_set_dostime(3)zip_file_set_external_attributes(3)zip_file_set_encryption(3)zip_file_set_mtime(3)zip_set_file_compression(3)zip_source_buffer(3)zip_source_file(3)zip_source_filep(3)zip_source_zip(3)
πΈ Rename Files
πΈ Delete Files
πΈ Revert Changes
πΈ Read/Modify Extra Fields
zip_file_extra_field_delete(3)zip_file_extra_field_delete_by_id(3)zip_file_extra_field_get(3)zip_file_extra_field_get_by_id(3)zip_file_extra_field_set(3)zip_file_extra_fields_count(3)zip_file_extra_fields_count_by_id(3)
πΈ Close Archive (Writing)
πΈ Miscellaneous (Writing)
zip_file_attributes_init(3)zip_libzip_version(3)zip_register_cancel_callback_with_state(3)zip_register_progress_callback_with_state(3)zip_set_archive_comment(3)zip_set_archive_flag(3)zip_source(5)
π§ SOURCES π§
π Create Source
zip_source_buffer(3)zip_source_file(3)zip_source_filep(3)zip_source_function(3)zip_source_layered(3)zip_source_zip(3)
π Using Source
π Implementing Source
zip_source_pass_to_lower_layer(3)
π Source Life Cycle
π ERROR HANDLING π
zip_error_strerror(3)zip_strerror(3)zip_file_strerror(3)zip_file_get_error(3)zip_get_error(3)zip_error_init_with_code(3)zip_error_set(3)zip_error_set_from_source(3)zip_error_system_type(3)zip_errors(3)
π AUTHORS π
Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at>
absolute legends, we stan π«Ά
Debian edition, dated May 5, 2025 β that's the LIBZIP(3) energy right there. go forth and zip responsibly, bestie πβ¨π
π¦ where this page comes from
- arch rolling: libzip 1.11.4-1 Β· BSD
- fedora 43: libzip-devel 1.11.4-2.fc43 Β· BSD-3-Clause
- fedora 43: libzip-devel 1.11.4-2.fc43 Β· BSD-3-Clause
- fedora 44: libzip-devel 1.11.4-3.fc44 Β· BSD-3-Clause
- fedora 44: libzip-devel 1.11.4-3.fc44 Β· BSD-3-Clause
- nixpkgs unstable: libzip 1.11.4
- ubuntu resolute: libzip-dev 1.11.4-2 Β· BSD-3-Clause
- ubuntu stonking: libzip-dev 1.11.4-2build1 Β· BSD-3-Clause
- Copyright (C) 2005-2024 Dieter Baron and Thomas Klausner
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms