th_read(3)
π th_read β bestie we're reading AND writing tar header blocks π
ok so this is a libtar man page, the th_read(3) one, and honestly? it's giving short and iconic. two little functions, one big vibe. let's get into it π«Ά
β¨ NAME β¨
th_read, th_write β read and write a file header block from a tar archive
like. that's the whole job description. reading a header, writing a header. no cap. π
β¨ SYNOPSIS β¨
#include <libtar.h>
int th_read(TAR *t);
int th_write(TAR *t);
see how clean that is?? one header file, two functions, both taking a TAR *t and both handing you back an int. we love a symmetrical moment π
β¨ VERSION β¨
this man page is documenting version 1.2 of libtar. yes bestie, 1.2, write it down, don't be out here reading docs for the wrong version π
β¨ DESCRIPTION β¨
ok so, story time πΈ
th_read() reads the next block from the tar archive that's associated with the TAR handle t. and then β this is the main character part β it sets the current tar header associated with t to the contents of that block it just read. so like, the handle now knows what the header is. it's informed. it's in the know. periodt β¨
th_write() does the reverse glow-up: it takes the contents of the current tar header associated with t and writes them out to the tar archive associated with t. header goes in, header comes out. balanced. symmetrical. beautiful. π¦
β¨ RETURN VALUE β¨
- on successful completion,
th_read()andth_write()both return0. zero. the good number. slay π - on failure, they return
-1and seterrnoto an appropriate value. so like, if it goes wrong, checkerrno, she'll tell you what happened π - and on EOF,
th_read()returns1. yes,1, not0, not-1. that's its own little special signal and you gotta handle it, bestie, or you'll be confused for hours fr fr π
lowkey important: EOF is not an error here. it's a 1. don't conflate them or the vibes will be off π
β¨ ERRORS β¨
th_read() and th_write() will fail if:
EINVALβ less thanT_BLOCKSIZEblocks were read or written. like, you didn't get a full block?? that's anEINVAL, sorry babe π
β¨ SEE ALSO β¨
the block-level besties. go read those too, iykyk π
and that's the whole page, babes β¨ this one came to us from the University of Illinois, dated Jan 2001 β yeah, 2001, she's been serving tar headers since before some of us were born and she still ate π π
π¦ where this page comes from
- arch rolling: libtar 1.2.20-8 Β· BSD
- debian bookworm: libtar-dev 1.2.20-8+deb12u1
- fedora 43: libtar-devel 1.2.20-34.fc43 Β· MIT
- fedora 43: libtar-devel 1.2.20-34.fc43 Β· MIT
- fedora 44: libtar-devel 1.2.20-35.fc44 Β· MIT
- fedora 44: libtar-devel 1.2.20-35.fc44 Β· MIT
- nixos 26.05: libtar 1.2.20
- nixpkgs unstable: libtar 1.2.20
- ubuntu jammy: libtar-dev 1.2.20-8
- ubuntu jammy: libtar-dev 1.2.20-8ubuntu0.22.04.1
- ubuntu noble: libtar-dev 1.2.20-8.1build1
- ubuntu noble: libtar-dev 1.2.20-8.1ubuntu0.24.04.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms