th_get_pathname(3)
π th_get_pathname(3) β C Library Calls π
okay bestie, gather round, because today we're digging into libtar and pulling apart tar headers like it's a little gossip session π this page lives in section 3 of the manual, and it's all about the cute lil getter functions and the vibe-checking macros that tell you what's actually inside a tar header. no cap, it's lowkey essential if you're doing anything with tarballs in C.
β¨ NAME β¨
so here's the whole squad, and what each one does:
th_get_pathname,th_get_uid,th_get_gid,th_get_mode,th_get_crc,th_get_size,th_get_mtime,th_get_devmajor,th_get_devminor,th_get_linknameβ these ones extract individual fields of a tar header πΈTH_ISREG,TH_ISLNK,TH_ISSYM,TH_ISCHR,TH_ISBLK,TH_ISDIR,TH_ISFIFOβ these ones determine what kind of file a tar header refers to πTH_ISLONGNAME,TH_ISLONGLINKβ these ones determine whether the GNU extensions are in use π
π SYNOPSIS π
#include <libtar.h>
char *th_get_linkname(TAR *t);
char *th_get_pathname(TAR *t);
mode_t th_get_mode(TAR *t);
uid_t th_get_uid(TAR *t);
gid_t th_get_gid(TAR *t);
int th_get_crc(TAR *t);
off_t th_get_size(TAR *t);
time_t th_get_mtime(TAR *t);
major_t th_get_devmajor(TAR *t);
minor_t th_get_devminor(TAR *t);
int TH_ISREG(TAR *t);
int TH_ISLNK(TAR *t);
int TH_ISSYM(TAR *t);
int TH_ISCHR(TAR *t);
int TH_ISBLK(TAR *t);
int TH_ISDIR(TAR *t);
int TH_ISFIFO(TAR *t);
int TH_ISLONGNAME(TAR *t);
int TH_ISLONGLINK(TAR *t);
β VERSION β
this man page documents version 1.2 of libtar. periodt. π
π DESCRIPTION π
okay so here's the tea π
the th_get_*() functions extract individual fields from the current tar header associated with the TAR handle t. that's it, that's the whole job β you hand them the handle, they hand you back one specific piece of the header. iconic behavior, honestly.
the TH_IS*() macros are used to evaluate what kind of file is pointed to by the current tar header associated with the TAR handle t. like, is it a regular file? a symlink? a directory? a fifo? the macro checks and lets you know π¦
and the TH_ISLONGNAME() and TH_ISLONGLINK() macros evaluate whether or not the GNU extensions are used by the current tar header associated with the TAR handle t.
β οΈ heads up bestie: this last one is only relevant if theTAR_GNUoption was used whentar_open()was called. if you didn't pass that option, don't come asking these macros for answers, they simply do not have the context π
π SEE ALSO π
tar_open(3)β go read this one too, it's the main character of the whole libtar story, iykyk π
and that's the whole page, babe πΈ this one comes from the fine folks at the University of Illinois, dated Jan 2001 β yes, it's giving vintage, but it still slays πβ¨π
π¦ where this page comes from
- arch rolling: libtar 1.2.20-8 Β· BSD
- 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
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms