gd_raw_filename(3)
π gd_raw_filename β bestie edition π
okay so this is gd_raw_filename(3) from the GETDATA manual, and it's literally the "where does this file even LIVE" function. it hands you the pathname of a binary file inside a Dirfile. that's the whole vibe. let's get into it π¦
β¨ NAME β¨
gd_raw_filename β retrieve the pathname of a binary file in a Dirfile ποΈβ¨
πΈ SYNOPSIS πΈ
#include <getdata.h>
char *gd_raw_filename(DIRFILE *dirfile, const char *field_code);
π DESCRIPTION π
so the gd_raw_filename() function reports the pathname of the file backing the RAW field that you specified with field_code, inside the dirfile you passed in as dirfile. that's it. it's giving "tell me where this file is at" energy πββοΈ
and listen β if field_code happens to contain a valid representation suffix, bestie, it gets ignored. fully ignored. not even a little bit considered. π«₯
π RETURN VALUE π
on success, gd_raw_filename() returns the full pathname of the binary file associated with the specified field, sitting pretty in a newly-allocated buffer. β¨
by default that buffer is allocated with malloc(3), but you can swap in a different memory manager by calling gd_alloc_funcs(3) before you call this function. and the receipts? the caller is responsible for deallocating the returned buffer. that means YOU, bestie. free it. don't leave it hanging, that's a leak and we don't do that here π
on error, this function returns NULL and stores a negative-valued error code in the DIRFILE object, which you can grab with a subsequent call to gd_error(3). possible error codes, and yes we're listing every single one:
GD_E_ALLOCβ the library could not allocate memory. the malloc said no πGD_E_BAD_CODEβ the field specified by field_code was not found. it's not there. it never was. πGD_E_BAD_DIRFILEβ the supplied dirfile was invalid. the dirfile itself? fake. πGD_E_BAD_FIELD_TYPEβ the field specified by field_code was not a RAW field. wrong type, wrong vibe, wrong function. π«GD_E_UNKNOWN_ENCODINGβ the encoding scheme of the specified field could not be determined, or it wasn't understood by GetData. it's giving mystery encoding π
and if you want the actual descriptive error string for whatever went wrong, hit up gd_error_string(3). that's the one that actually talks. π£οΈ
π§ HISTORY π§
okay so a lil lore drop for you π
the get_raw_filename() function appeared in GetData-0.4.2. back then, the memory for the string it returned was managed by GetData. so you didn't have to worry about it. those were the days. π
then in GetData-0.7.0, this function got renamed to gd_raw_filename(). glow-up, honestly. β¨
and in GetData-0.8.0, the returned string changed to a malloc'd buffer, and the responsibility for freeing that buffer got passed to the caller. plot twist: now it's your problem π«
π SEE ALSO π
free(3)gd_entry(3)gd_error(3)gd_error_string(3)malloc(3)dirfile(5)dirfile-encoding(5)dirfile-format(5)
and that's the whole page, bestie π this was Version 0.10.0, dated 25 December 2016 β yes, a christmas day release, iconic behavior, whoever shipped that ate and left no crumbs π π¦ go free your buffers, ily, bye β¨
π¦ where this page comes from
- debian bookworm: libgetdata-doc 0.11.0-6
- debian trixie: libgetdata-doc 0.11.0-15
- fedora 43: getdata-devel 0.11.0-13.fc43 Β· GPL-2.0-or-later
- fedora 43: getdata-devel 0.11.0-13.fc43 Β· GPL-2.0-or-later
- fedora 44: getdata-devel 0.11.0-14.fc44 Β· GPL-2.0-or-later
- fedora 44: getdata-devel 0.11.0-14.fc44 Β· GPL-2.0-or-later
- nixos 26.05: getdata 0.11.0
- nixpkgs unstable: getdata 0.11.0
- ubuntu jammy: libgetdata-doc 0.11.0-3ubuntu1
- ubuntu noble: libgetdata-doc 0.11.0-13
- ubuntu questing: libgetdata-doc 0.11.0-15
- ubuntu resolute: libgetdata-doc 0.11.0-17build1
- ubuntu stonking: libgetdata-doc 0.11.0-17build2
- Copyright (C) 2016 D. V. Wiebe
- Copyright (C) 2008, 2009, 2010, 2013, 2016 D. V. Wiebe
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms