pack_fseek(3alleg4)
β¨ NAME β¨
pack_fseek β bestie, this is the little function that skips around inside a stream, from the Allegro game programming library π
π¦ SYNOPSIS π¦
#include <allegro.h>
int pack_fseek(PACKFILE *f, int offset);
π DESCRIPTION π
Okay so picture this: you've got a stream f, right? And you wanna move its position indicator somewhere else. That's literally all this does β it relocates the position indicator of the stream f to a new spot. Iconic behaviour, honestly. π
But here's the tea, and you need to hear it: this is NOT your regular fseek(). Standard fseek() is out here doing the most. pack_fseek() is way more lowkey, and by lowkey I mean restricted:
- It only supports movements that go forward, and only relative to the current position. So no going backwards, bestie, we only move onwards and upwards. π¦
- It only works on read-only streams.
- So yeah β do NOT pass negative offsets. Just don't. It's not gonna work out. π
β οΈ Also, and this is the big one: seeking is very slow when you're reading compressed files. Like, painfully slow. So please, for the love of everything, avoid seeking unless you are sure the file isn't compressed. No cap. π
Okay here's the vibe in code form:
input_file = pack_fopen("data.bin", "r");
if (!input_file)
abort_on_error("Couldn't open binary data!");
/* Skip some useless header before reading data. */
pack_fseek(input_file, 32);
See? Skipping 32 bytes of useless header before the good stuff. Main character energy. π
πΈ RETURN VALUE πΈ
Returns zero on success π«Ά β or a negative number on error π, and when that happens it stores the error code in errno. So check your errno, bestie, it's giving receipts.
π SEE ALSO π
That's the whole page, fr fr. This gem is from Allegro version 4.4.3 β shoutout to the Allegro girlies who wrote the manual, mwah πβ¨π Go forth and seek (forwards only, read-only streams, no compressed files, iykyk) π§π
π¦ where this page comes from
- debian bookworm: allegro4-doc 2:4.4.3.1-3 Β· Allegro-gift-ware
- debian trixie: allegro4-doc 2:4.4.3.1-5 Β· Allegro-gift-ware
- ubuntu jammy: allegro4-doc 2:4.4.3.1-2 Β· Allegro-gift-ware
- ubuntu noble: allegro4-doc 2:4.4.3.1-4.1build3 Β· Allegro-gift-ware
- ubuntu questing: allegro4-doc 2:4.4.3.1-6
- ubuntu resolute: allegro4-doc 2:4.4.3.1-7 Β· Allegro-gift-ware
- ubuntu stonking: allegro4-doc 2:4.4.3.1-9 Β· Allegro-gift-ware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms