ZIP_FOPEN(3)
π ZIP_FOPEN π
okay bestie, so this is ZIP_FOPEN(3) from the Library Functions Manual β yes the whole manual, it's the Library Functions one, we love a category. sit down, grab a strawberry π, we're opening files out of zip archives.
πΈ NAME πΈ
zip_fopen, zip_fopen_index β open a file in a zip archive for reading. that's the whole job. she opens, you read. slay. β¨
π§ LIBRARY π§
libzip (-lzip) β yeah you gotta link her in, no cap.
π SYNOPSIS π
#include <zip.h>
zip_file_t *
zip_fopen(zip_t *archive, const char *fname, zip_flags_t flags);
zip_file_t *
zip_fopen_index(zip_t *archive, zip_uint64_t index, zip_flags_t flags);
two icons, one vibe. π«Ά
β¨ DESCRIPTION β¨
so zip_fopen() opens the file named fname inside archive. simple. iconic.
the flags argument tells her how the name lookup should go down, according to the values described in zip_name_locate(3). and ALSO, you can or these bad boys in on top:
ZIP_FL_COMPRESSEDβ read the compressed data as-is. otherwise the data gets uncompressed byzip_fread(). pick your fighter πZIP_FL_UNCHANGEDβ read the original data straight from the zip archive, ignoring any changes made to the file. lowkey a flex, BUT: this is not supported by all data sources. so don't be shocked if it's giving "no" π
and zip_fopen_index()? she opens the file at position index. that's it, that's the whole girl.
if encrypted data is encountered, these functions call zip_fopen_encrypted(3) or zip_fopen_index_encrypted(3) respectively, using the default password set with zip_set_default_password(3). so like, she knows a guy. π
π₯ RETURN VALUES π₯
upon successful completion, a struct zip_file pointer is returned. main character energy, honestly.
otherwise, NULL is returned and the error code in archive is set to indicate the error. so check it. fr fr. π
π ERRORS π
[ZIP_ER_CHANGED]β the file data has been changed and the data source does not support rereading data.[ZIP_ER_COMPNOTSUPP]β the compression method used is not supported. not her fault, blame the format.[ZIP_ER_ENCRNOTSUPP]β the encryption method used is not supported.[ZIP_ER_MEMORY]β required memory could not be allocated. π[ZIP_ER_NOPASSWD]β the file is encrypted, but no password has been provided. bestie. the password.[ZIP_ER_READ]β a file read error occurred.[ZIP_ER_SEEK]β a file seek error occurred.[ZIP_ER_WRONGPASSWD]β the provided password does not match the password used for encryption. note that some incorrect passwords are not detected by the check done byzip_fopen(). so like, don't get too comfy. π[ZIP_ER_ZLIB]β initializing the zlib stream failed.
also, the function zip_fopen() may also fail and set zip_err for any of the errors specified for the routine zip_name_locate(3). she's versatile like that.
and the function zip_fopen_index() may also fail with ZIP_ER_INVAL if index is invalid. don't pass a bad index, that's on you. π
π SEE ALSO π
libzip(3), zip_fclose(3), zip_fread(3), zip_fseek(3), zip_get_num_entries(3), zip_name_locate(3), zip_set_default_password(3)
the whole friend group. go read them too. π
π¦ HISTORY π¦
zip_fopen() and zip_fopen_index() were added in libzip 1.0. vintage. still eating. β
π AUTHORS π
Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at> β the literal parents of this function, we stan. π«Ά
and that's the page bestie!! this cutie is from Debian, dated December 18, 2017, and she lives at ZIP_FOPEN(3) in the manual. mwah. π
β¨
π¦ where this page comes from
- arch rolling: libzip 1.11.4-1 Β· BSD
- debian trixie: libzip-dev 1.11.3-2 Β· BSD-3-Clause
- 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 questing: libzip-dev 1.11.3-2
- ubuntu resolute: libzip-dev 1.11.4-2 Β· BSD-3-Clause
- ubuntu stonking: libzip-dev 1.11.4-2build1 Β· BSD-3-Clause
- Copyright (C) 2003-2017 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