open_trunc(3)

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

🌸 NAME 🌸

bestie. open_trunc β€” open a file for writing. that's it. that's the girl. πŸ’–

(this lil page lives in the Library Functions Manual, iykyk)


✨ SYNTAX ✨

okay so first you gotta pull her in, like this:

#include <libowfat/open.h>

and then the signature itself, which is literally:

int open_trunc(const char *filename);

no cap, that's the whole vibe. πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

so open_trunc opens the file filename for write-only use and hands you back the file handle. main character behavior, honestly.

here's the tea though, and it's important πŸ‘‘

  • if the file already exists, it gets truncated to zero bytes length. like, gone. wiped. bye. πŸ’€
  • if it does not exist, it gets created with mode 0644. new file, fresh start, slay. ✨
  • and if there was an error opening or creating the file, open_trunc returns -1 and sets errno accordingly. not the glow-up we wanted but at least she tells you. 😭

🫢 SEE ALSO 🫢

go read these next, they're all part of the friend group:


and that's the whole page, bestie!! this one came from the Library Functions Manual, and the lil footer at the bottom is literally just open_trunc(3) again, saying her own name one more time on the way out. iconic. πŸ’…πŸŒΈ no version or date stamp on this one, just pure open_trunc(3) energy. mwah. πŸ¦‹πŸ’œ