ZIP_FREAD(3)
π ZIP_FREAD(3) β bestie, it's reading time π
okay so this is the ZIP_FREAD(3) page from the Library Functions Manual, and it's literally one function, but she's an icon and she deserves her flowers. sit down, grab a strawberry π, let's go.
β¨ NAME β¨
zip_fread β read from file π«Ά
πΈ LIBRARY πΈ
libzip (-lzip) β that's the link flag, don't forget it, iykyk
π SYNOPSIS π
#include <zip.h>
zip_int64_t
zip_fread(zip_file_t *file, void *buf, zip_uint64_t nbytes);
look at her. three args, one very specific return type. no cap.
π¦ DESCRIPTION π¦
so zip_fread() reads up to nbytes bytes out of file and drops them into buf, starting from wherever the current position in the file is rn (that's the zip_fseek(3) situation, go look at it, bestie).
after the read happens, the current position gets updated by the number of bytes actually read. so it moves forward by however much it gave you. the way that it justβ¦ advances. π
ngl, "up tonbytes" is doing a lot of work there β you do not get a promise ofnbytesbytes, you get a promise of at most that. check the return value. always check the return value. fr fr.
π RETURN VALUES π
- success β you get back the number of bytes actually read. not the number you asked for. the number you got. π
0β this is what you get when you callzip_fread()after you've already hit the end of the file. end of file, end of story, she's done. π-1β error. something went sideways. that's it, that's the vibe check and it failed. π
π SEE ALSO π
the whole girl group, go say hi π
β HISTORY β
zip_fread()was added in libzip 0.6. baby's first appearance π£- in libzip 0.10 the return type was changed from
ssize_ttozip_int64_t. glow up β¨ - in libzip 0.10 the type of
nbyteswas changed fromsize_ttozip_uint64_t. double glow up, same release, she was busy π
π AUTHORS π
Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at>
absolute legends, no notes π«Ά
and that's the whole page bestie!! this was the Debian build, dated September 11, 2024, and yeah it's still filed under ZIP_FREAD(3) because some things never change π go read your zip files, ily, bye!! πΈππ¦
π¦ 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-2022 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