zzip_entry_fopen(3)

πŸ“¦
version 0.13.78 Β· 4 versions
, in centos-stream 10, debian trixie, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– zzip_entry_fopen(3) β€” bestie edition πŸ’–

okay so this is a page from the zziplib Function List (yes that's the manual name, we're fancy here) and it's all about opening a file inside a zip disk so you can read it. five little functions, one big vibe. let's go πŸ¦‹


✨ NAME ✨

zzip_entry_fopen, zzip_entry_ffile, zzip_entry_fread, zzip_entry_fclose, zzip_entry_feof β€” open a file within a zip disk for reading πŸ”₯


🌸 SYNOPSIS 🌸

like, the whole squad in one place:

#include <zzip/fseeko.h>

zzip__new__ ZZIP_ENTRY_FILE*
zzip_entry_fopen(ZZIP_ENTRY* entry, int takeover)

zzip__new__ ZZIP_ENTRY_FILE*
zzip_entry_ffile(FILE* disk, char* filename)

zzip_size_t
zzip_entry_fread(void* ptr, zzip_size_t sized, zzip_size_t nmemb, ZZIP_ENTRY_FILE* file)

int
zzip_entry_fclose(ZZIP_ENTRY_FILE* file)

int
zzip_entry_feof(ZZIP_ENTRY_FILE* file)

πŸ‘‘ DESCRIPTION πŸ‘‘

πŸŽ€ zzip_entry_fopen

okay so zzip_entry_fopen takes an "entry" argument and either copies it or just takes it over as owner into a brand new ZZIP_ENTRY_FILE handle structure. and that structure? it also carries a zlib buffer for decoding, because of course it does, we're decoding things. πŸ’…

then it does a lil seek over to the file_header of the given "entry" and validates it for the data buffer that follows it. we also prefetch some data from the data buffer β€” literally trying to match the disk pagesize so future access is faster. thoughtful queen behavior πŸ‘‘

then zzip_entry_fread comes in and reads in chunks of pagesizes, which is the size of the internal readahead buffer.

if an error occurs then null is returned. not ideal but that's the deal bestie 😭

πŸ¦‹ zzip_entry_ffile

zzip_entry_ffile opens a file found by name. so it does a lil search into the zip central directory with zzip_entry_findfile, and whatever gets found first gets handed straight to zzip_entry_fopen. first come first served, no cap.

πŸ“ zzip_entry_fread

zzip_entry_fread reads more bytes into the output buffer you specified as arguments. the return value is null on eof or error β€” and here's the gag: the stdio-like interface can not distinguish between these, so you need to check with zzip_entry_feof to tell the difference. iykyk πŸ™ˆ

🧚 zzip_entry_fclose

zzip_entry_fclose releases any zlib decoder info needed for decompression and then dumps the ZZIP_ENTRY_FILE struct. clean exit, periodt.

⭐ zzip_entry_feof

zzip_entry_feof lets you distinguish an error from an eof condition. actually β€” if we found an error but we did already reach eof, then we just keep on saying that it was an eof, so the app can just continue. lowkey forgiving of us, honestly 🫢


🌈 AUTHOR 🌈

Guido Draheim <guidod@gmx.de>


Copyright (c) Guido Draheim, use under copyleft (LGPL,MPL)


and that's the whole page bestie!! this one came from zziplib 0.13.78, which is the source/version + date tag on the footer, so now you know exactly which release you're living in βœ¨πŸ’– go read some zip files, you main character πŸ“šπŸ‘‘