io_readfile(3)

πŸ“¦
version 0.34 Β· 3 versions
, in alpine 3.24, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu resolute, ubuntu stonking

πŸ’– io_readfile(3) πŸ’–

okay bestie, welcome to the Library Functions Manual corner of the libowfat universe 🌈 this one's short, sweet, and honestly kinda iconic β€” it's the lil guy that gets you a shiny new file descriptor pointed at a file on disk. no cap.


✨ NAME ✨

io_readfile β€” open a file for reading 🫢


🌸 SYNTAX 🌸

#include <libowfat/io.h>

int io_readfile(int64* d,const char* filename);

like, that's it. two args. one header. we love a minimal queen πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜• β€” io_readfile sets d to the number of a brand new descriptor that reads from the disk file named filename, and then it returns 1. that's the good ending. main character energy fr fr ✨

if something goes wrong though? 😭 it sets errno to indicate the error, and returns 0. and listen β€” when it fails, it does not create a new descriptor, and it does not touch d. so d stays exactly how you left it. no sneaky edits, no surprise side quests. she's respectful like that πŸ’œ

ngl this is the kind of function where you always check the return value. 1 = slay, 0 = check errno and cry a lil. πŸ™ˆ

πŸ‘‘ SEE ALSO πŸ‘‘

go read those too, bestie, the whole squad is valid πŸ”₯


sign-off time πŸŽ€ this lil page lives in the Library Functions Manual, it's all about io_readfile(3), and the footer at the very bottom just says io_readfile(3) right back atcha β€” that's the vibe, that's the brand, periodt πŸ’…βœ¨πŸ¦‹