ZIP_SOURCE_SEEK(3)

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

✨ ZIP_SOURCE_SEEK ✨ (that's the zip_source_seek page from the Library Functions Manual, bestie πŸ’–)

okay so real talk β€” this is a page from the Library Functions Manual and it's all about zip_source_seek, a lil function from libzip that lets you slide the read cursor around inside a zip source. it's giving "scrub to wherever you want in the file" energy. let's go πŸ¦‹


πŸ’« NAME πŸ’«

zip_source_seek β€” set read offset in zip source


πŸ“š LIBRARY πŸ“š

libzip (-lzip)

(yeah girl, you gotta link against it, no cap 🫢)


🌸 SYNOPSIS 🌸

#include <zip.h>

int
zip_source_seek(zip_source_t *source, zip_int64_t offset, int whence);

look at that signature. three args, one int back. iconic. πŸ’…


πŸ‘‘ DESCRIPTION πŸ‘‘

zip_source_seek() sets the current read offset for source. that's it, that's the whole job. it's the "where am i reading from now" setter.

and just like in fseek(3) (yes bestie, the classic), where you land depends on the whence argument β€” the offset gets counted relative from:

  • SEEK_SET β€” start of file πŸŒ…
  • SEEK_CUR β€” current read offset in file πŸ“
  • SEEK_END β€” end of file 🏁

so like, SEEK_SET is "from the very beginning, main character origin story", SEEK_CUR is "from wherever i'm standing right now", and SEEK_END is "from the back, counting backwards". pick your vibe, the offset does the rest. ✨


πŸ”₯ RETURN VALUES πŸ”₯

upon successful completion, 0 is returned. slay.

otherwise, -1 comes back and the error information in source is set to indicate the error. so if you get a -1, check source for the tea β€” it'll tell you what went wrong. 😭


🫢 SEE ALSO 🫢

(go read zip_source_is_seekable(3) first if you're not sure your source even can seek, iykyk 🌈)


πŸŽ€ HISTORY πŸŽ€

zip_source_seek() was added in libzip 1.0. so it's been here since the beginning, a true OG. πŸ‘‘


πŸ’œ AUTHORS πŸ’œ

Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at>

absolute legends, we stan. 🌟


and that's the whole page, bestie!! this one came from the Debian build, dated March 10, 2023, page ZIP_SOURCE_SEEK(3) β€” so if you're citing it or whatever, that's the version you're holding. now go forth and seek responsibly πŸ§šπŸ’–βœ¨

πŸ“¦ where this page comes from