readclose_append(3)

πŸ“¦
version 0.34 Β· 2 versions
  • 0.34 Β· alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.30 Β· fedora 43, fedora 44, ubuntu jammy
, in alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– readclose_append(3) πŸ’–

okay bestie, so this one is from the Library Functions Manual β€” yes, readclose_append(3), the lil library function that just gets it. sit down, grab a strawberry πŸ“, and let's talk about slurping a whole file straight into a stralloc.


✨ NAME ✨

readclose_append β€” read a whole file into a stralloc 🫢


✨ SYNTAX ✨

#include <libowfat/readclose.h>

ssize_t readclose_append(int fd,stralloc* sa,
                     size_t bufsize);

✨ DESCRIPTION ✨

so here's the tea πŸ«–: readclose_append reads the whole content into the stralloc sa, and β€” this is the iconic part β€” it appends it to whatever's already chillin' in there. it does not wipe what you had. it adds. main character energy, no cap.

the file gets read in chunks of bufsize bytes size. adorable little bites. 🍰

if everything worked fine, readclose_append returns 0. literally the best outcome. slay.

on error, readclose_append returns -1 and sets errno appropriately. 😭 so yeah, if you see that -1, check your errno, bestie β€” it's telling you exactly what went wrong, iykyk.

πŸ’€ real talk: -1 means something broke. don't just ignore it and vibe on. check errno, periodt.

✨ SEE ALSO ✨


and that's the whole thing, babe πŸŽ€ go forth and append. this page came to you straight outta the Library Functions Manual, filed under readclose_append(3) β€” take care of her, she's doing her best πŸ’…πŸ’œπŸ¦‹