LIBZIP(3)

πŸ“¦
version 1.11.4 Β· 4 versions
, in arch rolling, fedora 43, fedora 44, nixpkgs unstable, ubuntu resolute, ubuntu stonking

✨ 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

πŸ’– Close Archive

πŸ’– Get File Attributes

πŸ’– Miscellaneous


πŸ”₯ CREATING/MODIFYING ZIP ARCHIVES πŸ”₯

🌸 Create/Open Archive

🌸 Add/Change Files and Directories

🌸 Rename Files

🌸 Delete Files

🌸 Revert Changes

🌸 Read/Modify Extra Fields

🌸 Close Archive (Writing)

🌸 Miscellaneous (Writing)


🧚 SOURCES 🧚

🌟 Create Source

🌟 Using Source

🌟 Implementing Source

  • zip_source_pass_to_lower_layer(3)

🌟 Source Life Cycle


πŸ’€ ERROR HANDLING πŸ’€


πŸ‘‘ 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