gd_dirfilename(3)

✨ gd_dirfilename β€” bestie edition ✨

okay so this is a page from the GETDATA manual, and today we're learning about gd_dirfilename(3) β€” the little function that tells you what your Dirfile is actually called πŸ’…


🌸 NAME 🌸

gd_dirfilename β€” retrieve the name of a Dirfile πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <getdata.h>

const char *gd_dirfilename(DIRFILE *dirfile);

πŸ’– DESCRIPTION πŸ’–

so the way that gd_dirfilename() works is: it goes and queries a dirfile(5) database β€” the one you point at with dirfile β€” and it hands you back its name. and like, the name of a dirfile isn't just a cute little nickname, bestie, it's an absolute pathname that refers to the dirfile base directory. the whole path. no cap. πŸ”₯

and the dirfile argument? it has to point to a valid DIRFILE object, one that you already made by calling gd_open(3). no skipping steps, you can't just manifest a DIRFILE out of thin air πŸ™ˆ


⭐ RETURN VALUE ⭐

when it works? iconic. it returns a pointer to a constant string containing the pathname of the dirfile. slay. πŸ‘‘

when it doesn't work? gd_dirfilename() returns NULL, and it stores a negative-valued error code inside the DIRFILE object, which you can go get later with a subsequent call to gd_error(3). the possible error codes are:

  • GD_E_BAD_DIRFILE β€” the supplied dirfile was invalid. that's it. that's the one. πŸ’€

and if you want a whole descriptive error string for whatever went wrong, just call gd_error_string(3) and it'll spill the tea for you 🫢


🌈 HISTORY 🌈

  • the function dirfilename() first appeared in GetData-0.3.0. baby's first era ✨
  • in GetData-0.7.0, this function got renamed to gd_dirfilename(). glow-up, honestly.
  • in GetData-0.10.0, the error return from this function changed from -1 to a negative-valued error code. not me checking the receipts πŸ“

πŸ‘‘ SEE ALSO πŸ‘‘

gd_open(3), path_resolution(7)


and that's the whole vibe, bestie πŸ§šπŸ’œ this was Version 0.10.0, dated 25 December 2016 β€” merry everything, go forth and know your dirfile's name fr fr πŸ“